過(guò)濾器鏈error方式和request方式同時(shí)使用出錯(cuò)
最近在寫(xiě)程序時(shí)使用filter,同時(shí)使用error方式和request方式進(jìn)行過(guò)濾,在Web.xml中error配置在前request方式在后,但在過(guò)濾時(shí)只有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方式是否同時(shí)使用?
2016-01-07
肯定可以同時(shí)使用,你檢查下是不是
<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>
寫(xiě)錯(cuò)了。