美文网首页工作生活
springmvc 整合 shiro 无法访问控制器 404问题

springmvc 整合 shiro 无法访问控制器 404问题

作者: mml_慢慢来 | 来源:发表于2019-07-02 16:16 被阅读0次
    <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"/>
    

    推荐看看:点击打开链接

    相关文章

      网友评论

        本文标题:springmvc 整合 shiro 无法访问控制器 404问题

        本文链接:https://www.haomeiwen.com/subject/occthctx.html