title: @ModelAttribute fields are null in Spring controller
body: <p>I followed a tutorial to handle form submission in Spring. I wanted to populate my <code>TaskEntity</code> bean with the form and have this bean's values available in my controller's <code>taskSubmit</code> method. However, all of the properties of <code>task</code> in this method are null when I fill out the form and hit submit. The relevant code is as follows:</p>
  
  <p><strong>TaskEntity.java</strong></p>
  
  <pre><code>public class TaskEntity {
  
      private String title;
      private String description;
      private Date dueDate;
      private TaskPriority priority;
  
      public void setTitle(String title) 
      {
          this.title = title;
      }
  
      public String getTitle() 
      {
          return this.title;
      }
  
      public void setDescription(String description) 
      {
          this.description = description;
      }
  
  
      public String getDescription() 
      {
          return this.description;
      }
  
      public void setDueDate(Date dueDate) 
      {
          this.dueDate = dueDate;
      }
  
      public Date getDueDate() 
      {
          return this.dueDate;
      }
  
      public void setPriority(String priority) 
      {
          this.priority = TaskPriority.valueOf(priority);
      }
  
      public TaskPriority getPriority() 
      {
          return this.priority;
      }
  }
  </code></pre>
  
  <p><strong>addTask.jsp</strong></p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org"&gt;
  &lt;head&gt;
      &lt;title&gt;To Do List - Add Task&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/stylesheet.css"&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="tasks" th:action="@{/tasks}" th:object="${taskEntity}" method="post"&gt;
          &lt;p&gt;Title: &lt;input type="text" th:field="*{title}" /&gt;&lt;/p&gt;
          &lt;p&gt;Description: &lt;input type="text" th:field="*{description}" /&gt;&lt;/p&gt;
          &lt;p&gt;Due Date: &lt;input type="text" th:field="*{dueDate}" /&gt;&lt;/p&gt;
          &lt;p&gt;Priority: &lt;input type="text" th:field="*{priority}" /&gt;&lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" value="Submit" /&gt; &lt;input type="reset" value="Reset" /&gt;&lt;/p&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>TaskController.java</strong></p>
  
  <pre><code>@Controller
  public class TaskController {
  
      private static final String TASKS = "/tasks";
      private static final String ADD_TASK = "/addTask";
  
      @Autowired
      private TaskEntityDao taskEntityDao;
  
      ObjectMapper mapper = new ObjectMapper();
  
      @RequestMapping(value = TASKS, method = RequestMethod.GET)
      public ModelAndView readTasks() 
      {
          return new ModelAndView("tasks");
      }
  
      @RequestMapping(value = ADD_TASK, method = RequestMethod.GET)
      public String addTask(Model model)
      {
          model.addAttribute("taskEntity", new TaskEntity());
          return "addTask";
      }
  
      @RequestMapping(value = TASKS, method = RequestMethod.POST)
      public void taskSubmit(@ModelAttribute TaskEntity task)
      {
          // Fields for 'task' are all null!      
          taskEntityDao.createTask(task);
  
          readTasks();
      }
  }
  </code></pre>
  
  <p>I expected the <code>TaskEntity</code> passed to the view with <code>model.addAttribute("taskEntity", new TaskEntity());</code> was going to have the form values mapped to it's fields, but I must have missed something.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I am adding the view resolver code from my Spring config:</p>
  
  <pre><code>&lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="viewClass"
          value="org.springframework.web.servlet.view.JstlView" /&gt;
      &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  </code></pre>