Spring中时间格式注解@DateTimeFormat

在SpringMVC中Controller中方法参数为Date类型想要限定请求传入时间格式时,可以通过@DateTimeFormat来指定,但请求传入参数与指定格式不符时,会返回400错误。

如果在Bean属性中有Date类型字段,想再序列化转为指定格式时,也可用@DateTimeFormat来指定想要的格式。如下:

 

 

posted on 2019-03-08 08:33  时间朋友  阅读(29673)  评论(0编辑  收藏  举报

导航