Saturday 15 May 2010

Spring framework. Set proxy for all controller -


How can I set a proxy in the spring frame for all my controllers? I want to change the detail of the return of my controllers.

I think you are using Spring MVC 3. * and an XML configuration. If this is not the case then please tell me and I will update my answer accordingly.

The Spring MVC provides interface that can be used for all pre-and post process requests managed by the controllers. I recommend that you create and implement this interface and accordingly your controllers output To change, use the posthand () method.

Once you have completed your handler interceptor, you will need to give instructions to Spring MVC. The namespace configuration for Spring MVC makes it very easy as an example:

  & lt; Mvc: interceptor & gt; & Lt; MVC: Interceptor & gt; & Lt; Mvc: mapping path = "/ **" /> & Lt; Bean class = "com.example.MyInterceptor" /> & Lt; / MVC: Interceptor & gt; & Lt; / MVC: Interceptor & gt;   

In this example I am registering a single HandlerInterceptor, implemented by the class com.example.MyInterceptor. I am also configuring Spring MVC for handler interceptor implementation work on all requests. You can change the mapping to suit your application requirements.

No comments:

Post a Comment