Ale*_*den 8 java session tomcat url-rewriting
看起来像一个愚蠢的问题,答案是"不要使用encodeURL()!" 但是我正在使用在JSP中使用netui锚标签的代码库,我需要禁用将JSESSIONID写入URL,因为这是一个安全风险.
在WebLogic中,您可以通过在weblogic.xml中配置url-rewriting-enabled来配置它(我知道,因为我在WebLogic服务器中编写了该功能!).但是,我找不到Tomcat的等效配置选项.
Tomcat 6支持disableURLRewriting可以true在Context元素中设置的属性:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html#Common_Attributes
没有设置想到.但是,这是很容易通过创建第一项做Filter对听音url-pattern的利益(也许/*?),并取代ServletResponse以HttpServletResponseWrapper实现,其中encodeURL()的回报非常相同的论点未修改回来.
开球示例:
public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException {
chain.doFilter(request, new HttpServletResponseWrapper((HttpServletResponse) response) {
public String encodeURL(String url) {
return url;
}
});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7124 次 |
| 最近记录: |