- 浏览: 86723 次
- 性别:
- 来自: 武汉
最新评论
import java.lang.reflect.Method; import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; /** * 权限拦截器(DWR) * * @author Administrator * */ @Aspect public class DwrAuthInterceptor { private static final long serialVersionUID = 1L; static Log logger = LogFactory.getLog(DwrAuthInterceptor.class); /** * 声明切点 */ @Pointcut("execution(* com.orifound.aiim.web.struts.*DWR.*(..)))") public void DWRClassPointcut() { //System.out.println("切点执行!"); } /** * 声明切点 */ @Pointcut("execution(* com.orifound.aiim.web.struts.*.*DWR(..)))") public void DWRMethodPointcut() { //System.out.println("切点执行!"); } @Around("DWRMethodPointcut() || DWRClassPointcut()") public Object doAround(ProceedingJoinPoint pjp) throws Throwable{ // 获取连接点的方法签名对象 MethodSignature joinPointObject = (MethodSignature) pjp.getSignature(); // 连接点对象的方法 Method method = joinPointObject.getMethod(); Object [] objs = pjp.getArgs(); HttpSession session = null; //Class<?>[] parameterTypes = joinPointObject.getParameterTypes(); for (Object obj : objs) { //System.out.println(obj); if(obj instanceof HttpSession){ session = (HttpSession)obj; //System.out.println("DWR拦截器HttpSession:"+session); } } UCLkey uclKey = method.getAnnotation(UCLkey.class); if (session == null) { //throw new ApplicationException("请重新登陆!", null); throw new Exception("请重新登陆!", null); }else if (uclKey != null) { //if(uclKey.equals(session.getAttribute(""))) //throw new ApplicationException("对不起,您没有权限!", null); throw new Exception("对不起,您没有权限!", null); } // 连接点方法方法名 //String name = method.getName(); //Class<?>[] parameterTypes = method.getParameterTypes(); // 获取连接点所在的目标对象 //Object target = pjp.getTarget(); // 获取目标方法 //method = target.getClass().getMethod(name, parameterTypes); // 返回@AroundPointCut的注释对象 // AroundPointCut joinPoint = // method.getAnnotation(AroundPointCut.class); // if (!joinPoint.accessRead()) { // throw new ApplicationException("没有权限!", null); // } return pjp.proceed(); } }
- aspectjrt.jar (113.3 KB)
- 下载次数: 4
- aopalliance-1.0.jar (4.4 KB)
- 下载次数: 3
- aspectjweaver.jar (1.6 MB)
- 下载次数: 4
发表评论
-
关于继承的问题
2010-11-26 14:54 467继承的概念:举个例子说吧,教师和学生都继承人类,数学老 ... -
Java的Calendar和Date类
2010-11-25 15:51 848Java 语言的Calendar(日历),Date(日期),和 ... -
SimpleDateFormat类简介
2010-11-25 11:44 810java.text 类 SimpleDateFormat j ... -
RMI原理及实现
2010-11-19 10:59 835简介 RMI是远程方 ... -
Lucene3.0 对数据库数据进行搜索
2010-10-20 17:28 3344package com.orifound.aiim.web.u ... -
Lucene3.0分词原理与分词系统
2010-10-20 17:25 902分词原理 建立索引和 ... -
java POI读取excel
2010-10-20 10:46 1741POI读取excel2003和2007方法是一样的,主要就是用 ... -
MyEclipse快捷键
2010-10-20 10:13 751Eclipse本身很快的,但是加上了myeclipse后,就狂 ... -
EL表达式
2010-10-20 10:09 812EL表达式 1、EL简 ... -
tomcat启动和关闭
2010-10-20 10:01 1011startup.bat: java -Djava.util. ... -
详细讲解Java中log4j的使用方法
2010-10-20 09:42 1108详细讲解Java中log4j的使用方法 1、Log4j是什么? ... -
java聊天室
2010-10-19 13:35 881server: public class ServerMan ... -
Struts2 BaseAction
2010-10-19 13:24 2114public class BaseAction extends ... -
基于spring进行单元测试
2010-10-19 13:13 624public class JTest { stati ... -
java获得客户端IP
2010-10-19 13:09 919/** * 获得客户端IP地址 * @param ... -
struts2 自定义拦截器
2010-10-19 13:05 948struts.xml : <package name= ... -
Log4j配置日志文件输出路径
2010-10-19 12:50 1475### 将日志输出到控制台 ##log4j.appender ... -
error和exception有什么区别?
2010-10-19 12:46 859error 表示恢复不是不可能但很困难的情况下的一种严重问题。 ... -
描述一下JVM加载class文件的原理机制?
2010-10-19 12:45 2027描述一下JVM加载class文件的原理机制? JVM中类的装载 ... -
j2ee常用的设计模式?说明工厂模式。
2010-10-19 12:44 1005j2ee常用的设计模式?说明工厂模式。 Java中的2 ...
相关推荐
spring拦截器,高级参数绑定,controller返回值
AOP拦截器示例,告诉我们初学者理解aop,通过一个银行转帐说明问题。
NULL 博文链接:https://lpm528.iteye.com/blog/1259187
NULL 博文链接:https://rogerhunt.iteye.com/blog/608778
spring拦截器的简单例子.docx
spring mvc 拦截器获取请求数据信息 解压之后放到项目中 直接运行就可以了 (将流多次运用)
idea软件。SpringBoot的拦截器的博客所写的例子。preHandle()方法的返回值true和false的详细区别还未描述
这一版本的项目中新增了拦截器的一个demo
NULL 博文链接:https://bijian1013.iteye.com/blog/2142522
Spring AOP 拦截器 Advisor Spring AOP 拦截器 Advisor
Spring AOP四种创建通知(拦截器)类型
使用CGLIB编写的Spring的拦截器 非常使用的哦
Spring MVC 拦截器Spring MVC 拦截器
spring-boot 拦截器 登录拦截spring-boot 拦截器 登录拦截spring-boot 拦截器 登录拦截spring-boot 拦截器 登录拦截
主要介绍了Spring拦截器HandlerInterceptor接口代码解析,具有一定借鉴价值,需要的朋友可以参考下
初学者很容易将 Spring MVC 拦截器 和 Spring Cloud OpenFeign 拦截器搞混,误以为OpenFeign拦截器就是SpringMVC拦截器:Spring MVC拦截器发生在客户端 和 服务端之间,在客户端向服务端发送请求时进行拦截处理。...
自己spring boot 拦截器,可以自定义限制跳转路径及自定义不拦截哪些具体路径,具体设置可以看注释,一看就懂,引用哪些包已经包含了,不明白的请浏览,看到后第一时间给您回复
本篇文章主要介绍了使用spring拦截器实现日志管理实例,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。