web.xml配置
<filter> <filter-name>shiroFilter</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>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
spring-mvc.xml配置
<bean id="jdbcRealm" class="com.tydic.realm.ShiroRealm"></bean> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realms" ref="jdbcRealm"> </property> </bean> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager"/> <property name="loginUrl" value="/666.jsp"/> <!--<property name="successUrl" value="/success.jsp"/>--> <property name="unauthorizedUrl" value="/unauthorized.jsp"/> <property name="filterChainDefinitions"> <value> /=anon <!-- 释放静态资源--> /js/**=anon /css/**=anon /image/**=anon /i18n/**=anon /jsp/login/officeLogin=anon /jsp/login/**=anon <!--/login.jsp=authc /jsp/login/**=anon /main.jsp=anon--> /test.jsp=anon /index.jsp=anon /jsp/login/officeLogin=anon # everything else requires authentication: /** = authc <!-- /=anon /test.jsp=anon /public/common/*=anon /css/**=anon /images/**=anon /js/**=anon /i18n/**=anon /login=anon /slogin=anon /jsp/i18n/welcome=anon /jsp/login/officeLogin=anon /main/office=anon <!–所有的请求(除去配置的静态资源请求或请求地址为anon的请求)都要通过登录验证,如果未登录则跳到/login –> /** = auth--> </value> </property> </bean>
在集成过程中,在srping-mvc.xml的配置文件中配置了
<!-- <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> <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> --> 老是导致一些请求被拦截 所以把这两个bean注释掉 项目能够正常启动 在这里做个笔记以后好翻阅