I am currently using request.setAttribute () and request.getAttribute () as a means of transferring an object from a handler interceptor to a controller method. I do not see this as an ideal technique because it requires me to accept the HttpServletRequest as an argument to my controller methods. Spring does a good job of hiding the request object from the controllers, so I don't need it except for this purpose.
I tried using the @RequestParam annotation with the name I set in setAttribute (), but of course this did not work because the request attributes are not request parameters. As far as I know, there is no @RequestAttribute annotation for attributes for attributes.
My question is, is there a better way to pass objects from interceptors to controller methods without resorting to setting them as attributes on the request object?
source
share