Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>chage <strong>accept="application/json"</strong> to <strong>enctype="application/json"</strong> on your HTML form.</p> <p>Spring can not parse you post data for you did not set the current headers. When use @RequestBody the default accept enctype is application/json. try to one of this:</p> <ol> <li>set post headers="content-type=application/json" on you html form or js post function.</li> <li>set you controller to accept headers="content-type=application/x-www-form-urlencoded".</li> </ol> <p>Edit</p> <p>The enctype must the same as headers. Ok, the code now looks like one of those:</p> <pre><code>// the one @RequestMapping(value = "save", method = RequestMethod.POST) public @ResponseBody UserResponse save(@RequestBody User user) throws Exception { UserResponse userResponse = new UserResponse(); return userResponse; } &lt;/form&gt; &lt;form action="/webapp/history/save" method="POST" enctype="application/x-www-form-urlencoded"&gt; &lt;input name="userId" value="user"&gt; &lt;input name="location" value="location"&gt; &lt;input name="emailAddress" value="hello@hello.com"&gt; &lt;input name="commitMessage" value="I"&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; // the other @RequestMapping(value = "save", method = RequestMethod.POST, headers = {"content-type=application/x-www-form-urlencoded"}) public @ResponseBody UserResponse save(@RequestBody User user) throws Exception { UserResponse userResponse = new UserResponse(); return userResponse; } &lt;/form&gt; &lt;form action="/webapp/history/save" method="POST" enctype="application/json"&gt; &lt;input name="userId" value="user"&gt; &lt;input name="location" value="location"&gt; &lt;input name="emailAddress" value="hello@hello.com"&gt; &lt;input name="commitMessage" value="I"&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; </code></pre> <p>Try one of those above.</p> <blockquote> <p>I get the following error:</p> <p>HTTP Error 415: The server refused this request because the request entity is in a format not supported by the requested resource for the requested method ().</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload