码迷,mamicode.com
首页 > 编程语言 > 详细

spring aop中获取request对象

时间:2018-05-26 18:47:18      阅读:630      评论:0      收藏:0      [点我收藏+]

标签:stat   权限   对象   alt   管理   提示页面   自定义   request对象   let   

应用场景是简单做个后台的权限管理,目前还没吃透shiro,并且时间不多。

用aop切入systemService中以do开头的方法,获取session中的用户Id,查看用户是否具有修改权限,如果没权限,就抛出异常,交给自定义的异常处理器去处理,转向提示页面

RequestAttributes ra = RequestContextHolder.getRequestAttributes();  

ServletRequestAttributes sra = (ServletRequestAttributes) ra;  

HttpServletRequest request = sra.getRequest();

如果context报空指针就在web.xml中添加

<listener>
 <listener-class>
         org.springframework.web.context.request.RequestContextListener
 </listener-class>
</listener>

 

 

spring aop中获取request对象

标签:stat   权限   对象   alt   管理   提示页面   自定义   request对象   let   

原文地址:https://www.cnblogs.com/lvsunshine21/p/9093782.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!