Java – migrate to spring annotated controllers and traditional onsubmit methods
I'm trying to migrate from spring 2.0 to spring 3.0
Previously, I defined a controller mycontroller inherited from simpleformcontroller and wrote some logic in the onsubmit method All controllers with handler methods inherit from mycontroller Therefore, the logic written in onsubmit of mycontroller is used to execute all requests
Now, when I migrate to an annotated controller where my controller is a simple POJO, how can I ensure that onsubmit is executed every time? One way is to call onsubmit from all handler methods of all controllers It's troublesome
Who can propose any feasible solution Using @ modelattribute to annotate formbackingobject can ensure that all requests are called. Is there an analogy to the onsubmit method?
Solution
If you want to perform the same operation before each call of any annotated controller, you can use interceptors You can write your own interceptor by implementing the prehandle method