1. 程式人生 > >許可權由shiro控制後 如何在 web.xml中攔截404 500等等異常

許可權由shiro控制後 如何在 web.xml中攔截404 500等等異常

1.web.xml中有shiro框架

<filter>
   <!-- 這裡的 filter-name 要和 spring 的 applicationContext-shiro.xml
   裡的 org.apache.shiro.spring.web.ShiroFilterFactoryBean的 bean name 相同 -->
<filter-name>shiroSecurityFilter</filter-name>
   <filter-class>org.springframework.web.filter.DelegatingFilterProxy</
filter-class> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroSecurityFilter</filter-name> <url-pattern>/*</
url-pattern> //加上後面的 dispatcher就可以在web.xml中攔截ssm return後找不到檢視和500的異常  <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>ERROR</dispatcher> </filter-mapping>
//異常用error-page
<error-page
> <error-code>404</error-code> <location>/WEB-INF/itax/404.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/WEB-INF/itax/404.jsp</location> </error-page> <error-page> <error-code>403</error-code> <location>/WEB-INF/itax/404.jsp</location> </error-page>