OKOK
OKOK

Reputation: 249

Spring MVC interceptor

I need inputs related to Spring MVC, I have a URL to which a client will send a post request with an xml as the pay load. I plan to have a controller method which maps to the requested url, I want that xml to be validated/converted to an object using jaxb before controller method is executed. And also, the controller method should have only the object as the parameter to its methods and no httprequest etc.

So, how do I achieve this? Will interceptor be helpful? If yes, how will it be done?

I plan to use Spring 3.

Upvotes: 1

Views: 253

Answers (1)

M. Deinum
M. Deinum

Reputation: 124526

Simply use @RequestBody in conjunction with @Valid on a method argument and that is all you need.

public void myRequestHandlingMethod(@Valid @RequestBody YourJaxbObject jaxbObject) { … }

I strongly suggest you take a look at the Spring reference guide

Upvotes: 1

Related Questions