【发布时间】:2012-07-12 21:30:47
【问题描述】:
我正在尝试编写一个使用 JAXB 自动序列化和反序列化对象的简单 Web 服务:
@XmlRootElement
public class SimpleObject {
private int id;
private String name;
/* ... */
}
@Controller
public class SimpleObjectController {
@RequestMapping("submit",method=RequestMethod.POST)
public String doPost(@RequestBody SimpleObject value) {
return value.toString();
}
}
<?xml version="1.0"?>
<beans ...>
<oxm:jaxb2-marshaller id="marshaller" class="path.to.objects"/>
</beans>
然而,当我实际提出请求时,我得到以下信息:
HTTP Status 415
The server refused this request because the request entity is in a format not
supported by the requested resource for the requested method ().
我没有从 Spring 收到任何日志,这让我很难确定根本原因。这个过程中是否有我遗漏的关键步骤?
【问题讨论】: