jsp 跳轉controller頁面 報400


跳轉報400,很有可能是jsp頁面傳遞的參數和controller接收的參數類型不一致,這里的參數一致是指 和實體類中保持一致。

當jsp頁面中出現date字段時,在controller中需要實現Converter接口進行處理,否則會報400異常。

在controller中如下:

@InitBinder
public void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)throws Exception {
DateFormat fmt=new SimpleDateFormat("yyyy-MM-dd");
CustomDateEditor dateEditor=new CustomDateEditor(fmt, true);
binder.registerCustomEditor(Date.class, dateEditor);
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM