/**
* 处理空字符串
*
* @param binder
*/
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
}
只需要在你的Controller里面加上这个就可以解决这个问题。如果觉得在每个controller里面写复杂,就弄一个BaseController,然后将上面的代码放在里面,其他Controller继承这个就行 。