栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Spring MVC中删除URL重写中的jsessionid

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Spring MVC中删除URL重写中的jsessionid

要点:只要用户不登录或不执行POST操作,就不要让您的应用创建会话。请勿致电

request.getSession()
request.getSession(true)
。不要为未登录的用户创建或管理会话范围的Bean。确保您正在使用的框架不会不必要地创建会话,除非您先声明要这样做。

如果由于应用程序的设计方式或所用(MVC)框架的局限性/错误而 确实
无法做到这一点,那么最好的选择是将Googlebot请求重定向到没有JSESSIONID标识符的URL。您可以为此使用Tuckey的URL重写过滤器(即Apache
HTTPD的Java变体

mod_rewrite
)。以下是其配置示例页面中的相关摘录。

隐藏来自Googlebot的请求的jsessionid。


<outbound-rule>     <name>Strip URL Session ID's</name>     <note>         Strip ;jsession=XXX from urls passed through

response.enpreURL().
The characters ? and # are the only things we can use to find
out where the jsessionid ends.
The expression in ‘from’ below contains three capture groups,
the last two being optional.
1, everything before ;jesessionid
2, everything after ;jesessionid=XXX starting with a ? (to
get the query string) up to #
3, everything ;jesessionid=XXX and optionally ?XXX starting
with a # (to get the target)
eg,
from index.jsp;jsessionid=sss?qqq to index.jsp?qqq
from index.jsp;jsessionid=sss?qqq#ttt to index.jsp?qqq#ttt
from index.jsp;jsessionid=asdasdasdsadsadasd#dfds -
index.jsp#dfds
from u.jsp;jsessionid=wert.hg - u.jsp
from /;jsessionid=tyu - /



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/495248.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号