title: How to get a form's data after the user submitted it with Spring MVC?
body: <p>i am getting an error message:
  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.ClassCastException: java.lang.Object cannot be cast to com.crimetrack.business.Login</p>
  
  <p>Login.java</p>
  
  <pre><code>public class Login {
  
      private String userName;
      private String password;
      private boolean loggedin;
  
      public Login(){};
  
      /**
       * @return the loggedin
       */
      public boolean isLoggedin() {
          return loggedin;
      }
  
      /**
       * @param loggedin the loggedin to set
       */
      public void setLoggedin(boolean loggedin) {
          this.loggedin = loggedin;
      }
  
      /**
       * @param userName
       * @param password
       */
      public Login(String userName, String password) {
          this.userName = userName;
          this.password = password;
      }
  
      /**
       * @return the userName
       */
      public String getUserName() {
          return userName;
      }
  
      /**
       * @param userName the userName to set
       */
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      /**
       * @return the password
       */
      public String getPassword() {
          return password;
      }
  
      /**
       * @param password the password to set
       */
      public void setPassword(String password) {
          this.password = password;
      }
  
  }
  </code></pre>
  
  <hr>
  
  <pre><code>@Controller
  public class AuthenticationController {
  
      private final Logger logger = Logger.getLogger(getClass());
  
      private AuthenticationManager authenticationManager;
      private Login login = new Login();
  
      String message = "Congrulations You Have Sucessfully Login";
      String errorMsg = "Login Unsucessful";
  
      @RequestMapping(value="login.htm")
      public ModelAndView onSubmit(Object command) throws ServletException {
  
          String userName = ((Login)command).getUserName();
          String password = ((Login)command).getPassword();
  
          login.setUserName(userName);
          login.setPassword(password);
  
          logger.info("Login was set");
  
          logger.info("the username was set to " + login.getUserName());
          logger.info("the password was set to " + login.getPassword());
  
          if (authenticationManager.Authenticate(login) == true){
              return new ModelAndView("main","welcomeMessage", message);
          }
  
          //return new ModelAndView("main","welcomeMessage", message);
          return new ModelAndView("login","errorMsg", "Error!!!");
      }
  
  }
  </code></pre>