title: send data from jsp to controller using model attribute
body: <pre><code>&lt;body&gt;
  &lt;jsp:useBean id="loginBean" class="com.ss.sms.bean.LoginBean"&gt;&lt;/jsp:useBean&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-xs-10 col-xs-offset-1 col-sm-8 col-sm-offset-2 col-md-4 col-md-offset-4"&gt;
              &lt;div class="login-panel panel panel-default"&gt;
                  &lt;div class="panel-heading"&gt;Log in&lt;/div&gt;
                  &lt;div class="panel-body"&gt;
  
                      form:form id="loginForm"  method="post" action="login" modelAttribute="login"&gt;
                      &lt;fieldset&gt;
                          &lt;div class="form-group"&gt;
                              &lt;input class="form-control" placeholder="UserId" name="userId" type="text" autofocus="autofocus" value=${loginBean.userName}&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                              &lt;input class="form-control" placeholder="Password" name="password" type="password" value=${loginBean.password}&gt;
                          &lt;/div&gt;
                          &lt;div class="checkbox"&gt;
                              &lt;label&gt;
                                  &lt;input name="remember" type="checkbox" value="Remember Me"&gt;Remember Me
                              &lt;/label&gt;
                          &lt;/div&gt;
                          &lt;input type="submit" class="btn btn-primary"&gt;
                          &lt;div style="color: red"&gt;${error}&lt;/div&gt;
                      &lt;/fieldset&gt;
                  &lt;/form:form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;&lt;!-- /.col--&gt;
  &lt;/div&gt;&lt;!-- /.row --&gt;    
  
  @RequestMapping(value="/login",method = RequestMethod.POST)
  public ModelAndView login(Model md,@ModelAttribute("login")LoginBean loginBean) {
      System.out.println("hello done");
      System.out.println(loginBean.getUserName());
      ModelAndView model = null;
      if (loginBean != null &amp;&amp; loginBean.getUserName() != null &amp; loginBean.getPassword() != null) {
          if (loginBean.getUserName().equals("santosh") &amp;&amp; loginBean.getPassword().equals("Santosh@123")) {
              model = new ModelAndView("hello");
              return model;
          } else {
              model = new ModelAndView("login");
              return model;
          }
      } else {
          model = new ModelAndView("login");
          return model;
      }
  }
  </code></pre>