使用什么策略确定JSON或XML?
问题内容:
使用Spring时,同时返回JSON和XML的最佳实践是什么?
说我有一个方法:
@RequestMapping(value="items/{id}", method = RequestMethod.GET)
public Item getItem(@PathVariable, Long id) {
// Find and return item.
}
我如何以这样的方式调用此方法: localhost:8080/app-name/items/1.xml
和localhost:8080/app- name/items/1.json
并以各自的格式获取数据?
问题答案: