課程
/后端開發(fā)
/Java
/Shiro安全框架入門
為什么@RequiresRoles無效,我是跟著視頻敲的,springmvc.xml注解我也寫了的
2018-06-16
源自:Shiro安全框架入門 4-3
正在回答
可以去掉<aop:config> 添加<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">?? ?<property name="proxyTargetClass" value="true" /></bean> 試試
<?xml?version="1.0"?encoding="UTF-8"?> <beans?xmlns="http://www.springframework.org/schema/beans" ???????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ???????xmlns:context="http://www.springframework.org/schema/context" ???????xmlns:mvc="http://www.springframework.org/schema/mvc" ???????xmlns:aop="http://www.springframework.org/schema/aop" ???????xsi:schemaLocation="http://www.springframework.org/schema/mvc?http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd ??????http://www.springframework.org/schema/beans?http://www.springframework.org/schema/beans/spring-beans.xsd ??????http://www.springframework.org/schema/context?http://www.springframework.org/schema/context/spring-context-4.3.xsd ??????http://www.springframework.org/schema/aop?http://www.springframework.org/schema/aop/spring-aop-4.2.xsd"> ????<context:component-scan?base-package="com.wb.controller"> ????</context:component-scan> ????<!--?1、這里對?/?與?/*?作扼要說明: ?????????/?是??根目錄 ?????????/*?是攔截所有請求,包括.html等靜態(tài)文件 ?????????(以區(qū)別于url-pattern中的?/) ?????????2、這里既然攔截所有請求,但是卻不會影響Controller ?????????主要是因為,所有請求先經(jīng)過dispatcherServlet ?????????才會進入到??spring-mvc.xml?文件中--> ????<mvc:resources?location="/"?mapping="/*"/> ????<aop:config?proxy-target-class="true"></aop:config> ????<bean?class="org.apache.shiro.spring.LifecycleBeanPostProcessor"></bean> ????<bean?class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> ????????<property?name="securityManager"?ref="securityManager"/> ????</bean> ????<mvc:annotation-driven/> </beans>
第一,你可以看看和數(shù)據(jù)庫里的權(quán)限設(shè)置是否一致,是不是值寫錯了。
第二,你用@RequiresRoles注解的話理論上來說不需要在配置攔截的url,如果配置了也應(yīng)該保持和注解一致,你最好把xml文件里的貼出來
影子愛月 提問者
舉報
從零入門Shiro安全框架
2 回答使用了@RequiresRoles如果沒有該角色拋出異常前端怎么處理
2 回答自定義過濾器無效
3 回答無法注入JedisUtil
2 回答Bean屬性“cookieRememberMeManager”不可寫或具有無效的setter方法。setter的參數(shù)類型是否與getter的返回類型匹配
1 回答點擊登錄無反應(yīng)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-06-29
可以去掉<aop:config> 添加<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor">
?? ?<property name="proxyTargetClass" value="true" />
</bean> 試試
2018-06-20
2018-06-18
第一,你可以看看和數(shù)據(jù)庫里的權(quán)限設(shè)置是否一致,是不是值寫錯了。
第二,你用@RequiresRoles注解的話理論上來說不需要在配置攔截的url,如果配置了也應(yīng)該保持和注解一致,你最好把xml文件里的貼出來