但 如果把BROWSER的COOKIE功能關掉 就會跑出來了 (因為OOXX我懶得寫的原因)
註:如果套用以下內容 可能會有功能遺失 EX需登入的功能之類
先寫一個FILTER
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
* @author i-memo
*/
public class DisableUrlSessionFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
ServletException {
if (!(request instanceof HttpServletRequest)) {
chain.doFilter(request, response);
return;
}
HttpServletResponse httpResponse = (HttpServletResponse) response;
HttpServletResponseWrapper wrappedResponse = new HttpServletResponseWrapper(httpResponse) {
public String encodeRedirectUrl(String url) {
return url;
}
public String encodeRedirectURL(String url) {
return url;
}
public String encodeUrl(String url) {
return url;
}
public String encodeURL(String url) {
return url;
}
};
chain.doFilter(request, wrappedResponse);
}
public void init(FilterConfig filterConfig) {
}
public void destroy() {
}
}
然後在WEB.XML設定
<filter>
<filter-name>DisableUrlSession</filter-name>
<filter-class>filter.DisableUrlSessionFilter </filter-class>
</filter>
<filter-mapping>
<filter-name>DisableUrlSession</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
參考資料:http://java.dzone.com/articles/java-jsessionid-harmful
沒有留言:
張貼留言