I use spring mvc 3.0, in our system there are some object like current user will be used in controller and in p开发者_Go百科age. Now, in all function, I always get user from spring security context, and set it into ModelMap, then it can be got in page. And in most of the function, the user object will also be got from ModelMap and used as some parameters. I want to know that, except interceptor, is there some way that I can set these objects into ModelMap before any function? And in interceptor, I can only set into request, but actually, some data are already in servlet context.
Thanks.
Try for this a annotation style as @PreHandle
with this can be annotated your method or function,
and means that Handler invoke execution of this function/method right before Dispatcher handle appropriate controller.
exact explain can be found here: http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/servlet/HandlerInterceptor.html
精彩评论