springMVC注解的时间注解不起作用

如题 配置@DateTimeFormat和 也有了joda-time

但注解@DateTimeFormat就是不起作用,一直报404
把这个注解去了 就没事,但时间格式就有问题了
The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). 上面是报的错误

使用注解.在需要转换的参数或实体类属性上添加@DateTimeFormatter(pattern=”表达式”)
2.1 使用Date参数接收
@RequestMapping("demo")
public String demo(@DateTimeFormat(pattern="yyyy-MM-dd") Date time){
System.out.println(time);
return "abc.jsp";
}

建议你在springmvc的配置文件中统一配置日期时间的转换,这样你就不用到controller中去转换了,前端只需要传一个时间字符串,后台就会自己映射成时间对象。

    <mvc:annotation-driven conversion-service="conversionService" validator="validator"/>

    <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
        <property name="formatters">
            <set>
                <bean class="org.springframework.format.Formatter接口的实现类,比如DateFormatter"/>
                <bean class="org.springframework.format.Formatter接口的实现类,比如TimestampFormatter"/>
            </set>
        </property>
    </bean>