Hello. In my spring project, I can't get the data in the @RequestBody argument. here is the controller:
@ResponseBody @RequestMapping(value = "submit" , method = RequestMethod.POST) public String submit(@RequestBody RequestData requestData) { System.out.println(requestData.getPeriod()); return "что-то там"; } js
$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "<c:url value="/submit" />", data: JSON.stringify({ period: $("input[name='PERIOD']").val() }) }); This is what json looks like, which is sent to the server:
{"period":"2016/07/08 21:04"} Here is the object itself:
@Data public class RequestData{ private String period; } Jackson-databind-2.8.4 library is connected to the project.
From the server comes the answer: status 415, description
It is not supported for the requested method.
Tell me please, in connection with which this can occur?
class RequestDatahaveclass RequestData/ set methods and an empty constructor? - MrFylypenkodataType: "json"parameter to the ajax requestdataType: "json"- mit