shiro配置, 若要shiro的註解起做用,則配置必須放在spring-mvc.xml中以下圖web
<!-- 視圖解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/" /> <property name="suffix" value=".jsp"></property> </bean> <!-- shiro 配置 --> <!-- 開啓Shiro註解 --> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> <!-- end shiro 配置 --> <!-- 統一異常處理! --> <bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="exceptionMappings"> <props> <!-- error1.jsp --> <prop key="org.apache.shiro.authz.UnauthorizedException">/error1</prop> <prop key="org.apache.shiro.authz.AuthorizationException">/error2</prop> </props> </property>