use of org.springframework.validation.ObjectError in project opennms by OpenNMS.
the class DefaultDistributedPollerServiceTest method testPauseLocationMonitorBindingErrors.
public void testPauseLocationMonitorBindingErrors() {
LocationMonitorIdCommand command = new LocationMonitorIdCommand();
BindException errors = new BindException(command, "command");
errors.addError(new ObjectError("foo", null, null, "foo"));
assertEquals("error count before pause", 1, errors.getErrorCount());
replayMocks();
m_distributedPollerService.pauseLocationMonitor(command, errors);
verifyMocks();
assertEquals("error count after pause", 1, errors.getErrorCount());
}
use of org.springframework.validation.ObjectError in project FS-Blog by JamesZBL.
the class UserController method fFrontUserLogin.
/**
* 前台用户登录
* 表单提交
*/
@PostMapping("/userlogin.f")
public String fFrontUserLogin(HttpServletRequest request, Model model, @Valid UserLoginForm loginForm, BindingResult bindingResult) throws Exception {
if (bindingResult.hasErrors()) {
List<ObjectError> errors = bindingResult.getAllErrors();
addModelAtt(model, VIEW_MSG, errors.get(0).getDefaultMessage());
return "userlogin";
}
User user = mUserService.loginAuthentication(loginForm);
if (null != user) {
mUserService.joinSession(request, user);
return "redirect:/";
}
addModelAtt(model, VIEW_MSG, "用户名或密码错误");
return "userlogin";
}
Aggregations