Intercept the view/response in Spring MVC 3

前端 未结 2 1616
野趣味
野趣味 2021-01-13 10:39

I am new to Spring MVC 3 and I understand the basic concepts. I am able to do simple things like create controllers and services and views. However, I haven\'t made a foray

2条回答
  •  不要未来只要你来
    2021-01-13 11:21

    Yes, a number of ways actually:

    • spring mvc interceptors (search for them in the mvc docs) - you can define the preHandle / postHandle methods and apply the interceptor to a number of controllers
    • spring aop - define an aspect to be executed before/after the methods of a given controller
    • servlet filters - this is the least desirable option, since it is not integrated with spring - you can't inject dependencies.

提交回复
热议问题