上干货.........

整合spring的配置文件

<?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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

<!-- filter-name这个名字的值来自于web.xml中filter的名字 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<!--登录页面 如果没有登录 访问项目的方法或页面 直接跳转到这个页面 -->
<property name="loginUrl" value="/login.jsp"></property>
<!--登录后 在访问没有经过授权的方法或页面时 直接跳转到这个页面 -->
<property name="unauthorizedUrl" value="/unauthorized.jsp"></property>
<property name="filterChainDefinitions">
<!-- /**代表下面的多级目录也过滤 过滤器链 -->
<value>
/login.jsp = anon
/css/** = anon
/img/** = anon
/plugins/** = anon
/make/** = anon
/favicon.ico= anon
/login.do = anon
/** = authc
</value>
</property>
</bean>

<!-- 引用自定义的realm
<bean id="saasRealm" class="cn.itcast.realm.SaasRealm"/>
-->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<!-- <property name="realm" ref="saasRealm"/>-->
</bean>
<!-- 安全管理器 -->
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"/>
</bean>

<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>

<!-- 生成代理,通过代理进行控制 -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
depends-on="lifecycleBeanPostProcessor">
<property name="proxyTargetClass" value="true"/>
</bean>

<aop:aspectj-autoproxy proxy-target-class="true"/>
</beans>

注意的事项

shiro的过滤器是有配置顺序的,

/login.do = anon 不拦截

/company/list.do = perms["企业管理"] 需要有对应的权限来访问

/** = authc 只要登录了就可以进行访问

shiro的优化

shiro的缓存优化

最新文章

  1. ABP模块化
  2. ASP.NET MVC图片上传
  3. IOS-01零碎知识总结
  4. c++相关的类型推导
  5. C语言sizeof
  6. History(历史)命令用法15例
  7. 我和小美的撸码日记(3)之一句话搞定MVC表单页数据绑定与提交
  8. Python 使用Pillow模块生成验证码
  9. linux 获取CPU个数
  10. Junit4测试报错
  11. Jmeter 后置处理器JSON Extractor 提取json的多个值
  12. 原生JS制作简易Tabs组件
  13. Python-数据类型1
  14. [ZJOI2007]矩阵游戏【bzoj1059/洛谷1129】/ [HEOI2016/TJOI2016]游戏
  15. 【BZOJ3997】【TJOI2015】组合数学 Dilworth定理 DP
  16. 从零开始一起学习SLAM | 点云平滑法线估计
  17. js对当前时间的相关操作
  18. SRAM、DRAM、SDRAM、DDR、DDR2、DDR3
  19. 用Qemu搭建x86_64学习环境
  20. webdriver鼠标上下滑动

热门文章

  1. 区块链入门到实战(21)之以太坊(Ethereum) – 分布式应用(DApp)
  2. 02 . Go开发一个日志收集平台之Context及etcd简单使用
  3. C++字符串与指针
  4. CF1270B Interesting Subarray 题解
  5. .NET5.0 Preview 8 开箱教程
  6. Urule开源版系列4——Core包核心接口之规则解析过程
  7. 那些jdk中坑你没商量的方法
  8. oracle坑。
  9. Git深入浅出使用教程:Git安装、远程控制、常用命令(全)
  10. python好用的测试库-Nose