객체에 @DateTimeFormat
이라는 주석을 달았습니다. 왜 인식하지 못합니까?@DateTimeFormat을 인식하지 못했습니다.
{
"timestamp": 1493708443198,
"status": 400,
"error": "Bad Request",
"exception": "org.springframework.http.converter.HttpMessageNotReadableException",
"message": "Could not read JSON document: Can not construct instance of java.time.LocalDateTime: no String-argument constructor/factory method to deserialize from String value ('2015-09-26T01:30:00.000')\n at [Source: [email protected]; line: 5, column: 23] (through reference chain: net.petrikainulainen.spring.trenches.model.Topic[\"localDateTime\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.time.LocalDateTime: no String-argument constructor/factory method to deserialize from String value ('2015-09-26T01:30:00.000')\n at [Source: [email protected]; line: 5, column: 23] (through reference chain: net.petrikainulainen.spring.trenches.model.Topic[\"localDateTime\"])",
"path": "/api/topics"
}
:
내 주요 아이디어는 문자열이 컨트롤러로 수신되면, 그것은 내가 갖는 순간 LocalDateTime 객체
로 변환하는 것입니다 게시하려고합니다
{
"id": "javaw2",
"name": "java code",
"descript2ion": "java description",
"localDateTime": "2015-09-26T01:30:00.000"
}
이것은 m입니다. Y 컨트롤러 :
@RequestMapping(method = RequestMethod.POST, value = "/topics")
public void addTopic(@RequestBody Topic topic) {
topicService.addTopic(topic);
}
는 설명 주셔서 감사합니다. 그것은 매우 도움이되었다 –
고마워 친구;) –