こんにちは、Spring で Web サービスを開始しているので、Spring + JSON + Hibernate で小さなアプリケーションを開発しようとしています。HTTP-POST に問題があります。メソッドを作成しました:
@RequestMapping(value="/workers/addNewWorker", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
@ResponseBody
public String addNewWorker(@RequestBody Test test) throws Exception {
String name = test.name;
return name;
}
そして、私のモデル Test は次のようになります。
public class Test implements Serializable {
private static final long serialVersionUID = -1764970284520387975L;
public String name;
public Test() {
}
}
POSTMAN では、単純に JSON {"name":"testName"} を送信していますが、常にエラーが発生します。
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Jackson ライブラリをインポートしました。私の GET メソッドは正常に動作します。何が間違っているのかわかりません。私はどんな提案にも感謝しています。