使用spring框架,在修改页面(修改一个日期,页面日期格式为 yyyy-MM-dd HH:mm:ss)时出现错误:
<td> <input type="text" name="createtime" value="<fmt:formatDate value="${item.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>" /> </td>
The request sent by the client was syntactically incorrect.客户端发送的请求语法是错误的
解决办法:在你的controller里加上如下代码
@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));
}