关于@DateTimeFormat的使用,求教没有转换date类型成功及客户端报错的原因?

controller的配置:
@RequestMapping(value = "/{day}/test.do", method = RequestMethod.GET)
public void test(@PathVariable @DateTimeFormat(iso=ISO.DATE) Date day) {
System.out.println(day);
}

执行的链接:
http://localhost:8080/whWeb/userManager/2009-11-17/test.do

返回:
HTTP Status 400 -


type Status report

message

description The request sent by the client was syntactically incorrect ().


Apache Tomcat/6.0.29

System.out.println(day)也没有执行

报错说的是你请求的语法有问题

但是我这是没有报错

// requires Joda-Time on the classpath
官方例子里关于类型转换的demo中提到了这点
看看你有没有导入joda-time的jar包,没有到话导入下看看。

good luck!

我把官方的demo发给你 你参考下吧

[code="java"]// requires Joda-Time on the classpath
@RequestMapping("date/{value}")
public @ResponseBody
String date(@PathVariable @DateTimeFormat(iso = ISO.DATE) Date value) {
return "Converted date " + value;
}[/code]

[code="jsp"]<a id="date" class="textLink" href="<c:url value="/convert/date/2010-11-17" />">Date</a>[/code]