J2EE - 过滤器`doFilter`方法没有被调用

时间:2018-04-29 16:18:59

标签: servlets java-ee web-applications web.xml servlet-filters

这是web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->

<web-app>
    <servlet>
        <servlet-name>login</servlet-name>
        <servlet-class>servlets.Login</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>login</servlet-name>
        <url-pattern>/reg/login</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>register</servlet-name>
        <servlet-class>servlets.Register</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>register</servlet-name>
        <url-pattern>/reg/signup</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>dashboard</servlet-name>
        <servlet-class>servlets.Dashboard</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>dashboard</servlet-name>
        <url-pattern>/user/dashboard</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>logout</servlet-name>
        <servlet-class>servlets.Logout</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>logout</servlet-name>
        <url-pattern>/reg/logout</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>edit</servlet-name>
        <servlet-class>servlets.EditProfile</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>edit</servlet-name>
        <url-pattern>/user/controlpanel/edit</url-pattern>
    </servlet-mapping>




    <!--####################################################-->

    <filter>
        <filter-name>regAuth</filter-name>
        <filter-class>filters.RegPathAuthFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>regAuth</filter-name>
        <url-pattern>/myWebApp/reg/login.html</url-pattern>
        <url-pattern>/myWebApp/reg/signup.html</url-pattern>
    </filter-mapping>

    <filter>
        <filter-name>regAccess</filter-name>
        <filter-class>filters.RegPathAccessFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>regAccess</filter-name>
        <url-pattern>/myWebApp/reg/login</url-pattern>
        <url-pattern>/myWebApp/reg/signup</url-pattern>

    </filter-mapping>

    <filter>
        <filter-name>userAuth</filter-name>
        <filter-class>filters.UserPathAuthFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>userAuth</filter-name>
        <url-pattern>/myWebApp/user/*</url-pattern>
        <url-pattern>/myWebApp/user/controlpanel/*</url-pattern>

    </filter-mapping>
    <filter>
        <filter-name>userAccess</filter-name>
        <filter-class>filters.UserPathAccessFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>userAccess</filter-name>
        <url-pattern>/myWebApp/user/dashboard.html</url-pattern>
        <url-pattern>/myWebApp/user/controlpanel/edit.html</url-pattern>
    </filter-mapping>
</web-app>

我检查过所有内容并多次调试项目并且没有找到问题所在。将调用所有4个过滤器的init方法,但是在发送请求时,不会调用doFilter方法。我找不到任何线索是什么问题。

那么,我该如何解决这个问题呢?我在哪里做错了?

如果您需要过滤器实现,请与我们联系。

此致

0 个答案:

没有答案