最近在写程序时使用filter,同时使用error方式和request方式进行过滤,在Web.xml中error配置在前request方式在后,但在过滤时只有error起作用,request不起作用。
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<filter>
<filter-name>ErrorFilter</filter-name>
<filter-class>com.roy.filter.ErrorFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ErrorFilter</filter-name>
<url-pattern>/error.jsp</url-pattern>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<filter>
<filter-name>LoginCheckFilter</filter-name>
<filter-class>com.roy.filter.LoginCheckFilter</filter-class>
<init-param>
<param-name>noFilterPaths</param-name>
<param-value>login.html;LoginCheck;noLogin.jsp;style.css</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>LoginCheckFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
不知error方式和request方式是否同时使用?
肯定可以同时使用,你检查下是不是
<filter>
<filter-name>LoginCheckFilter</filter-name>
<filter-class>com.roy.filter.LoginCheckFilter</filter-class>
<init-param>
<param-name>noFilterPaths</param-name>
<param-value>login.html;LoginCheck;noLogin.jsp;style.css</param-value>
</init-param>
</filter>
写错了。