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

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

Spring中时间格式注解@DateTimeFormat

 

Spring中时间格式注解@DateTimeFormat

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2021-09-29
  • 2022-12-23
  • 2021-12-23
  • 2021-07-03
猜你喜欢
  • 2021-08-14
  • 2022-01-03
  • 2021-07-01
  • 2021-04-24
  • 2022-12-23
  • 2021-04-22
相关资源
相似解决方案