"The request sent by the client was syntactically incorrect ()"问题定位及解决:

Spring MVC "The request sent by the client was syntactically incorrect ()"解决办法:

把spring日志级别调整到debug级别,可以看到更多的前端请求后台的日志,可以更精确的定位到底哪里出错了。

log4j.properties添加一行:

log4j.logger.org.springframework=DEBUG  

看到console控制台日志:日期转换异常。一般是你前端的页面的日期传到后台,格式转换异常。需要你重新设置下日期格式,前后端要对应。

解决方法:Controller层加入转换方法

   /*
     * 解决createTime格式转换问题Date to String
     */
    @InitBinder  
    public void initBinder(WebDataBinder binder) {  
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
        dateFormat.setLenient(false);  
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    }

 

参考文献:http://blog.csdn.net/yiluoak_47/article/details/10821747

posted @ 2016-05-23 10:48  走上学习不归路  阅读(3774)  评论(0)    收藏  举报