URL 重写

1. URL重写的目的。下边描述的比较好,但好像这对于java后台基于spring开发不是问题,controller中可以轻易实现读取URL 中的path variable。

Changing a URL to the required format. URL rewriting allows URLs to be more easily remembered by the user. When the URL is entered into the Web server, the URL rewrite engine modifies the syntax behind the scenes to enable the appropriate Web page or database item to be retrieved. For example, to look up the definition for "path," a user friendly URL might look like computerlanguage.com/path. The rewrite engine could turn it into the following syntax: computerlanguage.com/results.php?definition=path. See URL.
 

另外URL重写还有以下应用:

1). 针对浏览器端禁用cookie的情况,可以将session信息写入下一个访问的URL中。比如如下文档介绍的:

https://blog.csdn.net/qq_42857603/article/details/82897870

2). 据说还可以方便搜索殷勤搜索,不太清楚其中原理。

2. URL重写实现方式。

1) . 在http server中配置

https://www.cnblogs.com/zhenghongxin/p/6798310.html

2). 通过tomcat配置。

https://www.cnblogs.com/ttjava/p/3641014.html

3). 当然还可以在java 后台程序中重写响应给客户端的html页面里边包含的超级链接URL。但这跟上边两种情况,在收到第一个HTTP 请求就将请求对象的URL重写,然后交给后台程序处理(比如servlet 或者controller)还不是一个层面的意思。上边说的将session写入下一个访问的URL中,实际上就是利用这个所谓的重写机制来实现。感觉这一点也叫URL重写,有点勉强。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值