11

web.xml

<filter>
    <filter-name>SessionCheckFilter</filter-name>
    <filter-class>filter.SessionCheckFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>SessionCheckFilter</filter-name>
    <url-pattern>/faces/app/admin/*</url-pattern>
</filter-mapping>

我试图排除/faces/app/admin/index.xhtml唯一的,有没有办法做到这一点?

如果 web.xml 中没有排除 url 模式,也许我可以操纵该doFilter()方法来排除 url?

4

1 回答 1

0
      public void doFilter(ServletRequest servletRequest,
                     ServletResponse servletResponse,
                     FilterChain filterChain) throws IOException,
                                                     ServletException {
        HttpServletRequest request=(HttpServletRequest)servletRequest;

           String path = request.getPathInfo();
          if ((path != null) && (!path.equals("your path")){
         // write filter logic
            }
     }

试试上面的代码。

于 2015-06-03T10:11:17.757 回答