我在springmvc里用org.springframework.validation.BindingResult做验证代码如下@RequestMapping(value="/login")public String login(@Valid UserFrom userFrom, BindingResult result, Model m) throws Exception {if(result.hasErrors()) {if(null != result.getFieldError("email")) {m.addAttribute("emailErrorMessage", result.getFieldError("email").getDefaultMessage());}if(null != result.getFieldError("password")) {m.addAttribute("passwordErrorMessage", result.getFieldError("password").getDefaultMessage());} return "login";
}
return "redirect:/main";
}验证email和password现在的场景是:页面填写了email,验证通过页面没填写password,验证未通过,return "login"跳回到登陆页但是email文本框被清空了,怎么才能不清空呢,怎么办?
添加回答
举报
0/150
提交
取消