title: Spring MVC IllegalStateException
body: <p>I have a form in a modal window. This modal window can appear on any page from my website. From this form I want to send the information to my controller, but I get an exception. Let's me present my code:   </p>
  
  <p>This is my controller:</p>
  
  <pre><code>@RequestMapping(value = "/update-profile.html", method = RequestMethod.POST)
  public String modalUpdateProfile(
      @ModelAttribute("profile") Profile profil, BindingResult result, 
      Errors errors, RedirectAttributes ra
  ) {
      Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  
      if (!result.hasErrors()) {
          profileService.modifyAndUpdate(profil, auth.getName());
          return "redirect:/profilul-meu.html";
      }
      return "my-profile";
  }
  </code></pre>
  
  <p>And this is my form:</p>
  
  <pre><code>&lt;form:form method="POST" modelAttribute="profile" class="form-horizontal"
      action="${pageContext.request.contextPath}/update-profile.html"&gt;
      &lt;div class="col-md-5"&gt;
          &lt;div class="form-group"&gt;
              &lt;label for="nume"&gt;First Name: &lt;/label&gt;
              &lt;form:input id="nume" type="text" class="form-control"
                  path="first_name" /&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;label for="prenume"&gt;Second Name: &lt;/label&gt;
              &lt;form:input id="prenume" type="text" class="form-control"
                  path="second_name" /&gt;
          &lt;/div&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>This is my dipsatcher-servlet.xml:</p>
  
  <pre><code>    &lt;mvc:annotation-driven /&gt;
  &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt;
  &lt;context:component-scan base-package="com.gab.gsn.controller" /&gt;
  
  &lt;bean id="tilesConfigurer"
      class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"&gt;
      &lt;property name="definitions"&gt;
          &lt;list&gt;
              &lt;value&gt;/WEB-INF/template-def/general.xml&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="viewClass"
          value="org.springframework.web.servlet.view.tiles3.TilesView" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>So, when I want visit an page of my application I get this message:</p>
  
  <pre><code>java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'profile' available as request attribute
      org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:144)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:117)
      org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)
      org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
      org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
      org.apache.jsp.WEB_002dINF.template_002ddef.layout_jsp._jspx_meth_form_005finput_005f0(layout_jsp.java:2343)
      org.apache.jsp.WEB_002dINF.template_002ddef.layout_jsp._jspService(layout_jsp.java:416)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
      org.apache.tiles.request.servlet.ServletRequest.forward(ServletRequest.java:265)
      org.apache.tiles.request.servlet.ServletRequest.doForward(ServletRequest.java:228)
      org.apache.tiles.request.AbstractClientRequest.dispatch(AbstractClientRequest.java:57)
      org.apache.tiles.request.render.DispatchRenderer.render(DispatchRenderer.java:47)
      org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:259)
  </code></pre>