In spring mvc 3.0, how can I set the content type of a particular action?
I want to set the action to return a json result.
In spring mvc 3.0, how can I set the content type of a particular action?
I want to set the action to return a json result.
In Spring 3, you generally don't need or want to set the context type yourself, it's usually unnecessary.
In the case of controllers that need to return JSON, the simplest way to return JSON is to return an instance of MappingJacksonJsonView from your handler method. This will set the content-type for you. Jackson now has built-in support in Spring 3.