我有一個Person類。如何用spring @RequestBody在休息客戶端發送post請求
class Person{
Integer id;
String firstName;
String lastName;
//other params, constructors, getters & setters
}
&我的方法是
@RequestMapping(value = "/test", method = RequestMethod.POST)
public void testPerson(
@RequestBody Person person){
...
}
現在我需要使用REST客戶端進行測試。我嘗試設置Firefox插件的「請求標題」部分,使其具有「名稱」=「Content-Type」和「value」=「application/x-www-form-urlencoded」 &然後在主體中添加參數,
id=1&firstName=aaa&lastName=bbb
,但它給404
您需要JSON格式發送有效載荷。 – Vaelyr