Hi all,I have a question for using Spring AspectJ.I want to create audit log when user do something and get user information from web session to create audit log. Can anyone provide examples of how to do this?
+2
A:
Spring MVC's DispatcherServlet
stores request in a thread-local variable (if you don't use Spring MVC, you may declare RequestContextListener
in web.xml
to do the same thing). This variable can be accessed via RequestContextHolder
:
HttpSession s = (HttpSession) RequestContextHolder
.currentRequestAttributes()
.resolveReference(RequestAttributes.REFERENCE_SESSION);
axtavt
2010-09-29 16:50:31