解决问题:There was an unexpected error (type=Bad Request, status=400)
There was an unexpected error (type=Bad Request, status=400.Validation failed for object='employee'.Error count: 1
·
错因:
报400,请求类型错误,最有可能就是时间转换问题
使用第三方组件进行前后端分离式开发时,传输值到后台时
出现请求错误,对象Employee验证失败
There was an unexpected error (type=Bad Request, status=400.Validation failed for object='employee'.Error count: 1
解决:
在springboot配置文件中修改默认日期格式
在springboot中默认日期格式为 2022/4/29 而有些第三方组件是 2020-4-29 这种形式,所以爆出400错误,请求类型对应不上,我们需要在yaml或者properties文件中修改配置
spring.mvc.data-format=yyyy-MM-dd
既然前端使用第三方组件日期以 2022-4-29 这种格式向我们后端传值,而不是2022/4/29这种格式
那么我们就去后端修改springboot的默认的格式为 yyyy-MM-dd 即可
更多推荐
所有评论(0)