filter中web.xml的filter-mapping设置问题。在线

tujunhui 2003-08-22 09:02:31
我有个问题,这样的过滤应该怎设置。
我有100个JSP(同一目录),我filter对98个JSP起作用。应该怎样写。
...全文
210 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tujunhui 2003-08-22
  • 打赏
  • 举报
回复
to: wellsoon(wellsoon)
你能不能帮我看看这个帖子
http://expert.csdn.net/Expert/topic/2175/2175299.xml?temp=.9156458
tujunhui 2003-08-22
  • 打赏
  • 举报
回复
在web.xml中
是不是只能一个个对应filter-mapping,98个就要写98个filter-mapping呢
wellsoon 2003-08-22
  • 打赏
  • 举报
回复

这个应该的doFilter里实现比较方便。
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) {
try {
String strURL = new String( ( (HttpServletRequest) request).
getRequestURL());
if (strURL.endsWith("不过滤的jsp1.jsp") ||strURL.endsWith("不过滤的jsp2.jsp") {
filterChain.doFilter(request, response);
}
else {
//进行过滤处理

}
catch (ServletException sx) {
filterConfig.getServletContext().log(sx.getMessage());
}
catch (IOException iox) {
filterConfig.getServletContext().log(iox.getMessage());
}
}
tujunhui 2003-08-22
  • 打赏
  • 举报
回复
有人知道吗?
tujunhui 2003-08-22
  • 打赏
  • 举报
回复
???

81,090

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧