title: Spring MVC login with popup
body: <p>I want to login with popup in Spring MVC.I use bootstrap for this.So I can open popup.But when I start app I am getting "either BindingResult nor plain target object for bean name 'loginModel' available as request attribute" error.login.jsp is a popup that I included into my index.jsp page.</p>
  
  <pre><code>&lt;body&gt;
  &lt;form:form method="post" action="login" modelAttribute="loginModel"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;Kullanıcı Adı:&lt;/td&gt;
              &lt;td&gt;&lt;form:input type="text" path="username" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;form:errors path="username" cssClass="red" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Şifre:&lt;/td&gt;
              &lt;td&gt;&lt;form:input type="password" path="password" /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;form:errors path="password" cssClass="red" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
      &lt;input type="submit" /&gt;
      &lt;input type="reset" /&gt;
  &lt;/form:form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>and here is my controller class;</p>
  
  <pre><code>@Controller
  public class LoginPageController {
  
  @RequestMapping(value = "/popupPages/login", method = RequestMethod.GET)
  public ModelAndView displayLogin(HttpServletRequest request,
      HttpServletResponse response) {
  ModelAndView model = new ModelAndView("login");
  model.addObject("loginModel", new LoginModel());
  return model;
  }
  
  @RequestMapping(value = "/popupPages/login", method = RequestMethod.POST)
  public ModelAndView actionLogin(HttpServletRequest request,
      HttpServletResponse response,
      @ModelAttribute("loginModel") LoginModel loginModel) {
  ModelAndView model = new ModelAndView();
  String username = loginModel.getUsername();
  String password = loginModel.getPassword();
  if (username.isEmpty() || password.isEmpty()) {
      model.addObject("error", "Kullanıcı adı veya şifre boş geçilemez!");
  } else {
      // TODO: Bu kısımda kontrol yapılacak olup kontrole göre yönlendirme
      // yapılacaktır.
  }
  return model;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Is there any wrong ?</p>