- springmvc 400错误之--timestamp引起
springmvc 400错误.参数类型不对,或有空值就会出这种错误.
主要是timestamp类型引起
:8080/teasoft/orderHistory/edit:1 Failed to load resource: the server responded with a status of 400 (Bad Request)

timestamp类型经过spingmvc返回数据,影响显示和编辑保存.要在javabean加注解.
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
public Timestamp getDatetime() {
return datetime;
}
====================
// @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Timestamp datetime;
在属性上这个标签是springmvc的,只能解决空值报400问题.不能解决显示和编辑的情况.
为什么这些解决方法都是要污染Javabean呢? 而不是在自己的框架上解决问题??

本文探讨了SpringMVC中出现400错误的原因,特别是由timestamp类型的参数引发的问题。通过在JavaBean中使用@JsonFormat注解,可以解决由于timestamp格式不匹配导致的显示和编辑保存问题。
6527

被折叠的 条评论
为什么被折叠?



