Spring AOP配置导致访问异常

Java_er 2016-09-15 08:27:03
切面配置如下:

@Aspect
@Component
public class LogAspect {

public LogAspect() {

}

@Pointcut("execution(* com.example.action..*.*(..))")
public void recordLog(){}

@Before("recordLog()")
public void beforeMethod(JoinPoint jp){
System.out.println("方法:"+jp.getSignature()+"开始执行前");
System.currentTimeMillis();
}

@After("recordLog()")
public void afterMethod(JoinPoint jp){
System.out.println("方法:"+jp.getSignature()+"执行之后");
}

@Around("recordLog()")
public void executeTimeStatics(ProceedingJoinPoint pjp) throws Throwable {
long startTime = System.currentTimeMillis();

pjp.proceed();

long endTime = System.currentTimeMillis();
System.out.println("方法:"+pjp.getSignature()+",处理耗时:"+(endTime-startTime));
}


}



20:23:02.834 [Timer-0] DEBUG org.quartz.utils.UpdateChecker - Checking for available updated version of Quartz...
20:23:05.260 [http-bio-9090-exec-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
20:23:05.261 [http-bio-9090-exec-1] DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Opening JPA EntityManager in OpenEntityManagerInViewFilter
20:23:05.297 [http-bio-9090-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'SpringMVCTest' processing GET request for [/mgr/toLogin.do]
20:23:05.298 [http-bio-9090-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /toLogin.do
20:23:05.300 [http-bio-9090-exec-1] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Returning handler method [public java.lang.String com.example.action.UserInfoAction.toLogin(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,org.springframework.ui.ModelMap) throws java.lang.Exception]
20:23:05.300 [http-bio-9090-exec-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'userInfoAction'
20:23:05.302 [http-bio-9090-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Last-Modified value for [/mgr/toLogin.do] is: -1
20:23:05.352 [http-bio-9090-exec-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'logAspect'
方法:String com.example.action.UserInfoAction.toLogin(HttpServletRequest,HttpServletResponse,ModelMap)开始执行前
方法:String com.example.action.UserInfoAction.toLogin(HttpServletRequest,HttpServletResponse,ModelMap),处理耗时:13
方法:String com.example.action.UserInfoAction.toLogin(HttpServletRequest,HttpServletResponse,ModelMap)执行之后
20:23:05.367 [http-bio-9090-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Null ModelAndView returned to DispatcherServlet with name 'SpringMVCTest': assuming HandlerAdapter completed request handling
20:23:05.367 [http-bio-9090-exec-1] DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
20:23:05.371 [http-bio-9090-exec-1] DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Closing JPA EntityManager in OpenEntityManagerInViewFilter
20:23:05.371 [http-bio-9090-exec-1] DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
20:23:28.794 [schedulerFactory_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers

...全文
302 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Java_er 2016-09-20
  • 打赏
  • 举报
回复
好奇怪。
Java_er 2016-09-18
  • 打赏
  • 举报
回复
引用 1 楼 sunyanxiong123 的回复:
@Pointcut("execution(* com.example.action..*.*(..))"),请问一下你定义的切点是什么???
有神马问题吗
Java_er 2016-09-17
  • 打赏
  • 举报
回复
引用 1 楼 sunyanxiong123 的回复:
@Pointcut("execution(* com.example.action..*.*(..))"),请问一下你定义的切点是什么???
拦截 com.example.action 包以及子包下的所有类的所有方法
半道道 2016-09-16
  • 打赏
  • 举报
回复
@Pointcut("execution(* com.example.action..*.*(..))"),请问一下你定义的切点是什么???

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧