springmvc 整合 shiro 無法訪問控制器 404問題

<aop:config proxy-target-class="true"/>

	<!--<aop:aspectj-autoproxy />-->

	<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
		<property name="securityManager" ref="securityManager"/>
	</bean>

這是springmvc.xml的配置,applicationContext.xml的配置如下

	<bean id="credentialsMatcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher">
		<property name="hashAlgorithmName" value="md5"/>
		<property name="hashIterations" value="2"/>
	</bean>

	<!-- 自定義realm -->
	<bean id="shiroDbRealm" class="cn.ddsxy.ddlx.shiro.ShiroDbRealm">
		<property name="credentialsMatcher" ref="credentialsMatcher"/>
	</bean>

	<!-- 安全管理器 -->
	<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
		<property name="realm" ref="shiroDbRealm"/>
	</bean>

	<!-- 基於Form表單的身份驗證過濾器 -->
	<bean id="formAuthenticationFilter"
		  class="org.apache.shiro.web.filter.authc.FormAuthenticationFilter">
		<property name="usernameParam" value="username"/>
		<property name="passwordParam" value="password"/>
		<property name="loginUrl" value="/login"/>
	</bean>
	<!-- Shiro的Web過濾器 -->
	<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
		<property name="securityManager" ref="securityManager"/>
		<property name="loginUrl" value="/login"/>
		<property name="unauthorizedUrl" value="/403"/>
		<property name="filters">
			<map>
				<entry key="authc" value-ref="formAuthenticationFilter"/>
			</map>
		</property>
		<property name="filterChainDefinitions">
			<value>
				/** = anon
			</value>
		</property>
	</bean>

	<!-- 保證實現了Shiro內部lifecycle函數的bean執行 -->
	<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

<aop:config proxy-target-class="true"/>

推薦看看:點擊打開鏈接



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章