title: Spring MVC/Hibernate/MySQL 400 Bad Request Error
body: <p>I'm building a blog in Java using Spring and Hibernate. I can't seem to figure out what is going on but I keep running into a Bad Request error when I try to add (save) a post and I can't figure out where I am wrong in my mapping. </p>
  
  <p>Error message: 
  <a href="https://i.stack.imgur.com/vAuFV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vAuFV.png" alt="enter image description here"></a></p>
  
  <p>Controller: </p>
  
  <pre><code>@Controller
  @RequestMapping("/blog")
  public class IndexController {
  
  @Autowired
  private PostService postService;
  
  @RequestMapping("/list")
  public String showPage (Model theModel) {
  
      // get posts from DAO
  
      List&lt;Post&gt; thePosts = postService.getAllPosts();
  
      // add the posts to the model
  
      theModel.addAttribute("allPosts", thePosts);
      return "allPosts";
  }
  
  @GetMapping("/showFormForAdd")
  public String showFormForAdd(Model theModel) {
  
      //create model attribute to bind form data
      Post thePost = new Post();
  
      theModel.addAttribute("post", thePost);
  
      return "postSuccess";
  }
  
  @PostMapping("/savePost")
  public String savePost(@ModelAttribute("post") Post thePost) {
      // save the post using our service
  
      postService.savePost(thePost);
      return "allPosts";
  }
  </code></pre>
  
  <p>Form snippet: </p>
  
  <pre><code> &lt;div class="table" id="container"&gt;
  
              &lt;form:form action="savePost" modelAttribute="post" 
   method="POST"&gt;
  
                  &lt;table&gt;
                      &lt;tbody&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;label&gt;Title:&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;form:input path="title" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;&lt;label&gt;Author:&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;form:input path="author" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;&lt;label&gt;Date:&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;form:input path="date" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;&lt;label&gt;Post:&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;form:input path="post" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;&lt;label&gt;&lt;/label&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type="submit" value="Save"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;/tbody&gt;
                  &lt;/table&gt;
              &lt;/form:form&gt;
              &lt;div style="clear: both;"&gt;&lt;/div&gt;
              &lt;p&gt;
                  &lt;a href="${pageContext.request.contextPath}/"&gt;Back to Home Page&lt;/a&gt;
              &lt;/p&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>All other pages are working correctly so far, just can't add an actual blog post. Any help is greatly appreciated. </p>