0
我想寫自動的序列化,並使用JAXB反序列化對象的一個簡單的Web服務:彈簧3和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那裏得到日誌,這使我很難確定根本原因。在這個過程中,我缺少一個關鍵的步驟嗎?
是的,我需要修改我的'curl'要求以及:'捲曲-X POST -d「 」 - H「Content-Type:application/xml」http:// localhost:9080/submit'。忘記了Spring有多特殊。 –
2012-07-12 22:46:05