【发布时间】:2013-11-22 17:13:23
【问题描述】:
我有一个 JSON 格式的字符串,我用 HTTP-PUT 将它发送到带有 Spring MVC 和 Hibernate 的服务器。
Controller:
@RequestMapping(value = "/", method = RequestMethod.PUT)
public ResponseEntity<Map<String, Object>> myTest(
@RequestHeader("a") String a,
@RequestBody MyTestClass b) { … }
JSON:
{
"number":"123",
"test":"11/14"
}
test 是 java.util.Date (MySQL -> date),我这样注释 POJO:
@Column(name = "TEST")
@DateTimeFormat(pattern = "MM/yy")
private Date test;
所以test 应该格式化为月/年。但我用 Firefox RESTClient 尝试过,我总是得到
The request sent by the client was syntactically incorrect. 删除 test,一切正常并按预期工作。
看来,@DateTimeFormat(pattern = "MM/yy") 有问题?
【问题讨论】:
标签: java mysql json spring hibernate