Bean Validation - Edit Account

UsersController.java
RequestMapping(value="/editAccount",method=RequestMethod.POST)
public String editAccount(@Valid User user, 
    BindingResult bindingResult, Principal principal) {
    
  if (bindingResult.hasErrors()) {
    return "users/editAccount";
  }
  
  //user.setEmail(principal.getName());
  
  int check = userService.editAccount(user);
  
  if (check != 1) {
    throw new RuntimeException(WebContants.EDIT_ACCOUNT_FAIL);
  }
  
  return "redirect:/users/changePasswd";
}
editAccount.jsp
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="sf" %>

<sf:form id="editAccountForm" action="editAccount" method="post" 
      modelAttribute="user" onsubmit="return check();">
<sf:errors path="*" cssClass="error" />
<table>
<tr>
  <td>Full Name</td>
  <td>
    <sf:input path="name" /><br />
    <sf:errors path="name" cssClass="error" />
  </td>
</tr>
<tr>
  <td>Mobile</td>
  <td>
    <sf:input path="mobile" /><br />
    <sf:errors path="mobile" cssClass="error" />
  </td>
</tr>
<tr>
  <td>Password</td>
  <td>
    <sf:password path="passwd" /><br />
    <sf:errors path="passwd" cssClass="error" />
  </td>
</tr>
<tr>
  <td colspan="2"><input type="submit" value="Submit" /></td>
</tr>
</table>
</sf:form>

Test

After logging in, remove all existing values from the account modification form page and click the Submit button.

modify account test 1

modify account test 2

References