在做永和ssm项目时,修改订单信息时出现了问题,当点击提交就出现了以上错误.

错误400-The request sent by the client was syntactically incorrect

错误400-The request sent by the client was syntactically incorrect

The request sent by the client was syntactically incorrect 说的意思是:由客户端发送的请求是语法上是不正确的。

上网找了很多资料,大部分都是说前端jsp页面的控件名称(name)和controller中接收的参数名称不一致,检查以后确实存在这个问题,修改以后还是没有解决,这说明别的地方还存在问题。

网上还有一种说法,就是提交表单数据类型与model不匹配,或方法参数顺序错误,这主要是json时会出现这个问题,但我并没有用到json,是直接用类的,所以照着修改了以后还是没有解决。(详见http://cuisuqiang.iteye.com/blog/2054234

再有一种就是form表单中有日期,Spring不知道该如何转换,如要在实体类的日期属性上加@DateTimeFormat(pattern="yyyy-MM-dd")注解,添加以后确实解决了。

public class Order {
    private Integer id;
    private Integer doorId;
    private String orderNo;
    private String  orderType;
    private Integer pnum;
    private String cashier;
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date orderTime;
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date payTime;
    private String payType;
    private Double price;

jsp页面表单对应行

错误400-The request sent by the client was syntactically incorrect

相关文章: