title: pass arguments to spring controller with thymeleaf
body: <p>I am having trouble passing args from html to spring mvc 4 controller using thymeleaf 3.</p>
  
  <p>Here is the controller:</p>
  
  <pre><code>// Handler method for inserting currency:
  @RequestMapping(value = "/saveCurrency", method = RequestMethod.POST)
  public ModelAndView saveCurrency(@ModelAttribute("currency") Currency currency, BindingResult bindingResult, Model model)
  {
      model.addAttribute("currency", currency);
      currDAO.insert(currency);
  
      return new ModelAndView("redirect:/listCurr");
  }
  </code></pre>
  
  <p>And html form:</p>
  
  <pre><code>&lt;form action="/saveCurrency" th:action="@{/saveCurrency}" th:object="${currency}" th:method="post"&gt;
      &lt;input id="nameTB" type="text" th:field="*{name}" class="form-control" maxlength="3" style="text-transform:uppercase" /&gt;
      ...
  &lt;/form&gt;
  </code></pre>
  
  <p>I also have the class Currency with fields "id" and "name" and with getters and setters for them.
  Now with this code I get an error:</p>
  
  <blockquote>
    <p>SEVERE: Servlet.service() for servlet [dispatcher] in context with
    path [] threw exception [Request processing failed; nested exception
    is org.thymeleaf.exceptions.TemplateInputException: An error happened
    during template parsing (template: "ServletContext resource
    [/WEB-INF/views/listCurr.html]")] with root cause</p>
    
    <p>java.lang.IllegalStateException: Neither BindingResult nor plain
    target object for bean name 'currency' available as request attribute</p>
  </blockquote>
  
  <p>Any idea what am I doing wrong?</p>