我需要转发我的请求(一个jsp,但我不认为这是事情)从一个http.Filter
如果原始请求的URI通过我的过滤器运行的一些验证.
仍然需要说明如下:
>如何在doFilter()方法中获取ServletContext(为了调用转发API)getServletContext()不重新指定
>我必须在前进之前拨号chain.doFilter(),在前进还是不完成之后?
另外我必须调用chain.doFilter(),如果我的验证通过,或只有当它失败(因为在这种情况下,我不会继续转发我的页面)?
这个问题实际上持续了this thread,
更明显的是,代码可以是:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (request instanceof HttpServletRequest) {
HttpServletRequest httpServletRequest = ((HttpServletRequest)request);
String requestURI = httpServletRequest.getRequestURI();
String contextPath = httpServletRequest.getContextPath();
if (){
getServletContext().getRequestDispatcher(
"MySpecific.jsp").forward(request,response);
}
}
chain.doFilter(request,response);
}