开发者

how to make spring mvc to output xml response?

Does it has built-in support or I have to do java objects to xml converting by myself? An example would be very helpful. Thanks!开发者_StackOverflow


Assuming that you're using Spring 3, then you can have it automatically marshall the response to XML:

@RequestMapping("/someurl")
public @ResponseBody SomeObject someMethod() {

 ...
 return instanceOfSomeObject;
}

Then in your context you would register an instance of HttpMessageConverter that supports XML, such as MarshallingHttpMessageConverter (with an appropriate Marshaller configured).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜