在Web.xml中配置Filter的过滤路径时,可否exclude某些路径?
不可以。[u]there isn't an exclude pattern in the servlet spec[/u].
You would need to do it from within your Filter code.在doFilter中对路径进行判断处理。例如
不可以。[u]there isn't an exclude pattern in the servlet spec[/u].
You would need to do it from within your Filter code.在doFilter中对路径进行判断处理。例如
doFilter(ServletRequest req, ServletResponse res, FilterChain chain) {
if(req instanceof HttpServletRequest) {
HttpServletRequest hreq = (HttpServletRequest)req;
if(hreq.getRequestURI().endsWith("aaa.do"){
// do something
}
}
chain.doFilter(req, res);
}
本文详细阐述了如何在Web.xml中配置Filter以排除特定路径,通过在doFilter方法中进行路径判断处理,实现对指定URL的过滤逻辑。包括实例代码演示,帮助开发者更好地理解并应用此技巧。

846

被折叠的 条评论
为什么被折叠?



