zoukankan      html  css  js  c++  java
  • shiro添加注解@RequiresPermissions无效

    在学习和使用shiro中,需要整合shiro框架,然后可以在spring中中使用有三种方法,我用的是注解开发这种方式,但是,我加入注解后发现,没什么作用,然后想着肯定是没有注解成功,然后查找资料,发现是没有开启spring拦截器,那么怎么开启呢,如下所示

    在spring-mvc.xml中加入以下代码就可以了(一定要写在最先加载的xml中,写在后面加载的xml中也不起作用)

        <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>

    lifecycleBeanPostProcessor和securityManager是在shiro配置文件中定义好的

        <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"></bean>
    
        <!-- 配额securityManager -->
        <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
            <property name="realm" ref="customRealm" />
            <!-- 注入缓存管理器 -->
            <property name="cacheManager" ref="cacheManager"/>
        </bean>

    一会总结一下springmvc+shiro的整合配置

  • 相关阅读:
    预分频之三
    MySQL超时配置
    随机森林深入理解
    决策树算法——ID3
    指数平滑法
    最小二乘法的Java实现
    JS实战
    CSS布局实战
    Win7 Python开发环境搭建
    神经网络正向传播与反向传播公式
  • 原文地址:https://www.cnblogs.com/ningheshutong/p/6509740.html
Copyright © 2011-2022 走看看