The server cannot or will not process the request due to something that is perceived to be a client

Type Status Report

Description 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).

问题描述:访问400

原因:参数不能被识别或者参数有错误,检查form表单,还有就是表单中含有日期类型的数据也会有问题

解决:1.使用Spring的@DateTimeFormat注解

使用方法: 在对应的属性上或者其set方法上加上@DateTimeFormat注解, 这个注解有一个pattern属性, 可以指定要日期的格式.

就像这样:

@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birth;

还需要在配置文件中添加"mvc:annotation-driven"这个标签, 否则不生效.

这种方法最简单,只需添加两处配置即可. 但只是局部生效, 若需要转换的属性比较多, 就造成了注解编写的冗余.
————————————————
版权声明:本文为CSDN博主「forJL」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wn084/article/details/80171687

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值