title: Update form error - Spring4 mvc - org.springframework.beans.TypeMismatchException:
body: <p>I'm trying to create update form using Spring mvc. Once user click the update button it shows the current values in input tags. When I edit the current values and hit the submit button it shows the following error.</p>
  
  <blockquote>
    <p>org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver handleTypeMismatch
        WARNING: Failed to bind request element: org.springframework.beans.TypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'int'; nested exception is java.lang.NumberFormatException: For input string: "updateStudent"</p>
  </blockquote>
  
  <p><strong>home.jsp</strong></p>
  
  <pre><code>&lt;form:form method="GET" action="updateStudent" commandName="selectedUser"&gt;
          &lt;table&gt;
  
              &lt;tr&gt;
                  &lt;form:input path="userID" placeholder="userID"
                      value="${selectedUsers.userID}" /&gt;
                  &lt;form:input path="userName" placeholder="userName"
                      value="${selectedUsers.userName}" /&gt;
                  &lt;form:input path="password" placeholder="password"
                      value="${selectedUsers.password}" /&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;&lt;input type="submit" value="Submit" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form:form&gt;
  </code></pre>
  
  <p><strong>controller.java</strong></p>
  
  <pre><code>@RequestMapping(value = "updateStudent", method = RequestMethod.GET)
  
  public String updateStudent(@ModelAttribute("selectedUser") User user, 
          ModelMap model) throws Exception {
  
      Student student = new Student();
      System.out.println("come here helloController()");
      model.addAttribute("userID", user.getUserID());
      model.addAttribute("userName", user.getUserName());
      model.addAttribute("password", user.getPassword());
      model.addAttribute("student",student);
      model.addAttribute("user",user);
      System.out.println("student id is " + user.getUserID());
      // model.addAttribute("userI", user);
      if (user.getUserID() == 0) {
          model.addAttribute("error", "please enter id");
          return "home";
      }
      if (user.getUserName() == null) {
          model.addAttribute("error", "please enter getUserName");
          return "home";
      }
      if (user.getPassword() == null) {
          model.addAttribute("error", "please enter getPassword");
          return "home";
      }
      return "home";
  }
  </code></pre>
  
  <p><strong>User.java</strong></p>
  
  <pre><code>public class User {
      int userID;
      String userName;
      String password;
  
      public int getUserID() {
          return userID;
      }
  
      public void setUserID(int userID) {
          this.userID = userID;
      }
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  }
  </code></pre>
  
  <p>I need to pass the updated values to controller. Hope you got the question. Please help to figure out the issue.</p>