spring 表单提交的时候,属性为整型,页面值为空串时无法转换为空指针。
在你的派生类里重写commandcontrollor 的initBinder方法
protected
void
initBinder(HttpServletRequestrequest,ServletRequestDataBinderbinder)
throws Exception{
binder.registerCustomEditor(Integer. class , new CustomNumberEditor(Integer. class , true ));
}
throws Exception{
binder.registerCustomEditor(Integer. class , new CustomNumberEditor(Integer. class , true ));
}
可以解决这个问题 ................... spring作者的疏忽么.....
本文介绍了解决Spring框架中表单提交时遇到的问题,当表单属性为整型且值为空字符串时,无法转换为空指针。通过重写CommandController的initBinder方法并注册自定义编辑器来解决该问题。

287

被折叠的 条评论
为什么被折叠?



