title: Sending object from thymeleaf template to Rest Controller returns "Unsupported Media Type"
body: <p>I'm trying to POST some object fields to a RestController using thymeleaf. </p>
  
  <p>But the result of the post returns what looks like a parsing error : </p>
  
  <blockquote>
    <p>There was an unexpected error (type=Unsupported Media Type, status=415). Content type
    'application/x-www-form-urlencoded;charset=UTF-8' not supported</p>
  </blockquote>
  
  <p>The index page sends two attributes to the controller which then calls the business service that builds the new object.</p>
  
  <pre><code> &lt;!DOCTYPE html&gt;
  &lt;html xmlns:th="http://www.thymeleaf.org" lang="en"&gt;
  
  &lt;head&gt;
  
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;
  &lt;meta name="description" content=""&gt;
  &lt;meta name="author" content=""&gt;
  
  &lt;title&gt;Simple Sidebar - Start Bootstrap Template&lt;/title&gt;
  
  &lt;!-- Bootstrap core CSS --&gt;
  &lt;link th:href="@{/index/vendor/bootstrap/css/bootstrap.min.css}"
      rel="stylesheet"&gt;
  
  &lt;!-- Custom styles for this template --&gt;
  &lt;link th:href="@{/index/css/simple-sidebar.css}" rel="stylesheet"&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
          &lt;!-- Page Content --&gt;
          &lt;div id="page-content-wrapper"&gt;
              &lt;div class="container-fluid"&gt;
                  &lt;form action="#" th:action="@{/accounts}" th:object="${account}" method="post" enctype="application/json"&gt;
                      &lt;div class="form-row"&gt;
                          &lt;div class="form-group col-md-4 "&gt;
                              &lt;label for="inputState"&gt;Departement&lt;/label&gt;
                              &lt;input type="text" th:field="*{owner}"  class="form-control" placeholder="Type in the department ..." /&gt;
                              &lt;/div&gt;
                      &lt;/div&gt;  
                      &lt;div class="form-row"&gt;
                          &lt;div class="form-group col-md-4 "&gt;
                              &lt;label for="inputState"&gt;Budget&lt;/label&gt;
                              &lt;input type="number" step="0.01" th:field="*{budget}"  class="form-control" placeholder="Type in Budget ..." /&gt;
                              &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;button class="btn btn-primary" type="submit"&gt;Enregistrer&lt;/button&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;!-- /#page-content-wrapper --&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is the Rest Controller : </p>
  
  <pre><code>@RestController
  public class AccountController {
  
  @Autowired
  private AccountService accountService;
  
  @RequestMapping(value="/accounts", method=RequestMethod.POST)
  public void addAccount(@RequestBody Account account ) {
      accountService.addAccount(account);
  }
  
  }
  </code></pre>
  
  <p>Account is a simple POJO : </p>
  
  <pre><code>public class Account {
  
  
  private String id;
  private String owner;
  private double budget;
  private double budgetInvest;
  private double budgetFonction;
  
  public Account() {
  
  }
  
  public Account(String id,String owner, double budget, double budgetInvest, double budgetFonction 
          ) {
      super();
      this.id = id;
      this.owner=owner;
      this.budget = budget;
      this.budgetInvest = budgetInvest;
      this.budgetFonction = budgetFonction;
  }
  
  public Account (String owner, double budget) {
      this.owner = owner;
      this.budget=budget;
  }
  
  public String getId() {
      return id;
  }
  
  public void setId(String id) {
      this.id = id;
  }
  
  public double getBudget() {
      return budget;
  }
  
  public void setBudget(double budget) {
      this.budget = budget;
  }
  
  public double getBudgetInvest() {
      return budgetInvest;
  }
  
  public void setBudgetInvest(double budgetInvest) {
      this.budgetInvest = budgetInvest;
  }
  
  public double getBudgetFonction() {
      return budgetFonction;
  }
  
  public void setBudgetFonction(double budgetFonction) {
      this.budgetFonction = budgetFonction;
  }
  
  public String getOwner() {
      return owner;
  }
  
  public void setOwner(String owner) {
      this.owner = owner;
  }
  
  
  
  
  }
  </code></pre>
  
  <p>And the add method simply adds the object to a list of objects. </p>
  
  <p>What am i doing wrong here ? </p>