I have to log the request parameters/ form data before any bean/controller method is called. My application is written in spring web flow.
What would be the best way to implement it?
I have to log the request parameters/ form data before any bean/controller method is called. My application is written in spring web flow.
What would be the best way to implement it?
I think Spring AOP can help you.
Define a Pointcut expression that selects all your controller method and use the @Before advice to log the parameters
Example:
@Before("execution(@controllers.package * *(..))")
public void logArguments(JoinPoint joinPoint) throws Throwable {
logger.debug("Entering method - Arguments : " + joinPoint.getArgs());
}
If you need to intercept each request before reaching the controller, you can use interceptor. You will have to extend your class with HandlerInterceptorAdapter.You may override it's preHandle method to intercept each request before it reaches controller.You will get access to request and response objects in this method to change your target page or url.
You don't need AOP/Aspectj, you can do that with a Servlet Filter