怎么在过滤里转发URL

06-03-25 tianxie
public void doFilter(。。。) {

HttpServletRequest hreq = (HttpServletRequest) request;

HttpServletResponse hres = (HttpServletResponse) response;

//目的是如果请求的是/jsp2/xxx.xxx,那么转为/WEB-INF/jsp2/xxx.xxx

String s = hreq.getRequestURI();

int i = s.indexOf("jsp2");

s = s.substring(0, i) + "WEB-INF/" + s.substring(i);

RequestDispatcher dis = hreq.getRequestDispatcher(s);

dis.forward(hreq, hres);

filterChain.doFilter(request, response);

..........

}

对应的web.xml写:

<filter-mapping>

<filter-name>Jsp2UrlFilter</filter-name>

<url-pattern>/jsp2/*</url-pattern>

</filter-mapping>

可是不成功啊,请问怎么回事?

tianxie
2006-03-25 09:29

对应的web.xml写:
  <filter-mapping>
    <filter-name>Jsp2UrlFilter</filter-name>
    <url-pattern>/jsp2/*</url-pattern>
  </filter-mapping>   
<p>

aill
2006-03-30 12:56
这位用地也是想把动态页面转发到静态页面吧,我也在问这方面的问题。

一起关注

猜你喜欢