title: HTTP Status 500 - java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'myUser' available as request attribute
body: <p>I have a problem. Web.xml does not load the Welcome.jsp and also Am I correct in writing teh controller @RequestMapping value, I assume it is the URL and must map the req to the mentioned jsp.</p>
  
  <h2>Web.xml</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt;
  &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
  &lt;context-param&gt;  
  &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;  
  &lt;param-value&gt;/WEB-INF/mvc-dispatcher-servlet.xml&lt;/param-value&gt;  
  &lt;/context-param&gt; 
  &lt;listener&gt;  
  &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;  
  &lt;/listener&gt; 
  &lt;listener&gt;
  &lt;listener-lass&gt;org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
  &lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;servlet&gt;  
  &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;  
  &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;  
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;  
  &lt;/servlet&gt; 
  &lt;servlet&gt;
  &lt;servlet-name&gt;Tiles Dispatch Servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.apache.tiles.web.util.TilesDispatchServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;  
  &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;  
  &lt;url-pattern&gt;/&lt;/url-pattern&gt;  
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Tiles Dispatch Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.tiles&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;welcome-file-list&gt; 
  &lt;welcome-file&gt;/WEB-INF/pages/Welcome.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <h2>mvc-dispatcher.xml</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"  
  xmlns:context="http://www.springframework.org/schema/context"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="  
  http://www.springframework.org/schema/beans       
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
  http://www.springframework.org/schema/context   
  http://www.springframework.org/schema/context/spring-context-3.0.xsd
  http://www.springframework.org/schema/mvc
  http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  &lt;context:component-scan base-package="com.dev.controller" /&gt;  
  &lt;bean  
  class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;  
  &lt;property name="prefix"&gt;  
  &lt;value&gt;/WEB-INF/pages/&lt;/value&gt;  
  &lt;/property&gt;  
  &lt;property name="suffix"&gt;  
  &lt;value&gt;.jsp&lt;/value&gt;  
  &lt;/property&gt;  
  &lt;/bean&gt;  
  &lt;/beans&gt;
  </code></pre>
  
  <h2>Welcome.jsp</h2>
  
  <pre><code> &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
      &lt;%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %&gt;
      &lt;%@taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt;
      &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
      &lt;tiles:insertDefinition name="myapp.homepage" /&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;div id="welcomeTitle" class="title"&gt;
      &lt;h1&gt;Health Care Simulation - Welcome&lt;/h1&gt;
      &lt;/div&gt;
      &lt;div id="centerBody" class="body"&gt;
      &lt;form:form method="post" action="Welcome" modelAttribute="myUser"&gt;
      Enter Team Name:&lt;font color="red"&gt;&lt;form:errors path="teamName" /&gt;&lt;/font&gt;
      &lt;form:input path="teamName" /&gt;
      &lt;input type="submit" value="Submit" /&gt;
      &lt;/form:form&gt;
      &lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <h2>WelcomeController.java</h2>
  
  <pre><code>@RequestMapping(value = "/welcome")
  @Controller
  public class WelcomeController {
  
      @ModelAttribute("myUser")
  
      public TeamName getLoginForm(@RequestParam String user) {
          System.out.println("test");
          TeamName myUser = new TeamName();
          myUser.setTeamName(user);
          return myUser;
      }
  
      @RequestMapping(method = RequestMethod.GET)
      public String showForm(@ModelAttribute("myUser") TeamName myUser)       
              /*Map model*/ {
          System.out.println("test1");
          //myUser.addAttribute("myUser",myUser ); 
          /*TeamName myUser = new TeamName();
          model.put("myUser", myUser);*/
          return "myUser";
      }
      @RequestMapping(method = RequestMethod.POST)
      public String validateForm(
          @ModelAttribute("myUser") @Valid TeamName myUser,
          BindingResult result, Map model) {
          System.out.println("test1");
          if (result.hasErrors()) {
              return "welcome";
          }
  
          model.put("myUser", myUser);
  
          return "success";
  
      }
  
  }
  </code></pre>
  
  <h2>TeamName.java</h2>
  
  <pre><code>import javax.validation.constraints.Size;
  import org.hibernate.validator.constraints.NotEmpty;
  public class TeamName {
  
      @NotEmpty
      @Size(min = 1, max = 20)
      private String teamName;
  
      public String getTeamName() {
          return teamName;
      }
  
      public void setTeamName(String teamName) {
          this.teamName = teamName;
      }
  }
  </code></pre>