以前自已定义好Annonation类 ,然后将该注解放到方法上面。可以使用Spring Aop 拦截到。如下:
注解类
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReturnArgsToView {
public String argsName() ;
}
/code]
[code=Java]
@ReturnArgsToView(argsName="startdate")
public ModelAndView doSearchLog(Timestamp startdate, Timestamp enddate){}
AOP处理类如下
@Around(value = "@annotation(com.evertrip.etdspro.misc.annotations.ReturnArgsToView)")
public Object putArgsToResponse(ProceedingJoinPoint point) throws Throwable{
//......
}
现在我想对方法的参数,使用注解,但是用Aop就拦截不到了,求解决办法。 。如下:
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReturnArgsToView {
public String argsName() ;
}
/code]
[code=Java]
public ModelAndView doSearchLog(@ReturnArgsToView(argsName="startdate") Timestamp startdate, Timestamp enddate){}
处理Aop如下:
@Around(value = "@annotation(com.evertrip.etdspro.misc.annotations.ReturnArgsToView)")
public Object putArgsToResponse(ProceedingJoinPoint point) throws Throwable{
// 这样就拦截不到了。 不会进这个方法
}
注解类
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReturnArgsToView {
public String argsName() ;
}
/code]
[code=Java]
@ReturnArgsToView(argsName="startdate")
public ModelAndView doSearchLog(Timestamp startdate, Timestamp enddate){}
AOP处理类如下
@Around(value = "@annotation(com.evertrip.etdspro.misc.annotations.ReturnArgsToView)")
public Object putArgsToResponse(ProceedingJoinPoint point) throws Throwable{
//......
}
现在我想对方法的参数,使用注解,但是用Aop就拦截不到了,求解决办法。 。如下:
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReturnArgsToView {
public String argsName() ;
}
/code]
[code=Java]
public ModelAndView doSearchLog(@ReturnArgsToView(argsName="startdate") Timestamp startdate, Timestamp enddate){}
处理Aop如下:
@Around(value = "@annotation(com.evertrip.etdspro.misc.annotations.ReturnArgsToView)")
public Object putArgsToResponse(ProceedingJoinPoint point) throws Throwable{
// 这样就拦截不到了。 不会进这个方法
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货