"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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM