JSON-Post zu Spring Controller
Hallo, ich beginne mit Web Services im Frühjahr und versuche, eine kleine Anwendung in Spring + JSON + Hibernate zu entwickeln. Ich habe ein Problem mit HTTP-POST. Ich habe eine Methode erstellt:
@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;
}
Und mein Modelltest sieht so aus:
public class Test implements Serializable {
private static final long serialVersionUID = -1764970284520387975L;
public String name;
public Test() {
}
}
Per POSTMAN sende ich einfach JSON {"name": "testName"} und bekomme immer eine Fehlermeldung;
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Ich habe die Jackson-Bibliothek importiert. Meine GET-Methoden funktionieren einwandfrei. Ich weiß nicht, was ich falsch mache. Für Anregungen bin ich dankbar.