"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