public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain chain) throws IOException, ServletException {
String s=arg0.getParameter("rp");
if("1".equals(s))
{
try
{
long bef = System.currentTimeMillis();
System.out.println("*************");
arg0.setAttribute("kk","ppppppp" );
chain.doFilter(arg0, arg1);
new Exception();
}
catch(Exception e)
{
System.out.println("====================");
arg0.getRequestDispatcher("/usrlist.do").forward(arg0, arg1);
}
}
else
{
try
{
long bef = System.currentTimeMillis();
System.out.println("*************");
chain.doFilter(arg0, arg1);
}
catch(Exception e)
{
arg0.getRequestDispatcher("hello.jsp").forward(arg0, arg1);
}
}
}
本文详细解析了在Servlet-2.3与Servlet-2.4版本中Filter的不同行为,特别是对于forward和include操作的过滤处理,并通过实例展示了如何在配置中使Filter能够拦截这些内部转发请求,确保Filter的正常执行。
2087

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



