跳轉報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);
}
