title: How to pass errors in Spring Controller/Model to a view file
body: <p>How do I pass errors to a view file from a Controller implemented using Spring MVC? These errors are not form errors. Just business logic errors that will be shown inside a div in the "JSP" view.</p>
  
  <p>Here is the controller action I have:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.POST)
  public String processLoginForm(HttpServletRequest request, LoginForm loginForm, 
  BindingResult result, @SuppressWarnings("rawtypes") Map model) 
  {
      loginForm = (LoginForm) model.get("loginForm");
  
      String gotoURL = request.getParameter("gotoURL");
  
      if (gotoURL == null || gotoURL == "") 
      {
          String errorMessage = "No Redirect URL Specified"; 
          return "loginerror";//loginerror is the view file I want to pass my error to.
      }
      model.put("loginForm", loginForm);
      return "loginsuccess";
  }
  </code></pre>
  
  <p>Thanks,</p>