posting object spring restcontroller?
<p>I can't get this thing to work. The project works perfectly aside from when I try to post an actual object. I can post single strings just fine.</p>

<p>html:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="ISO-8859-1"&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;script
    src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;post test&lt;/h1&gt;
    &lt;button id="postButton"&gt;post&lt;/button&gt;
    &lt;script&gt;
        var myObject = {
            name : "Johnny",
            field : "something"
        };
        $(function() {
            $("#postButton").click(function() {
                $.post("posting", JSON.stringify(myObject), function(data, status) {
                    alert(status);
                });
            });
        });
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>controller:</p>

<pre><code>package app.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import model.MyObject;

@Controller
public class MainController {

    @RequestMapping(value = "/posting", method = RequestMethod.POST)
    @ResponseBody
    public void posting(@RequestBody MyObject myObject) {
        System.out.println(myObject.getName());
    }

}
</code></pre>

<p>myObject:</p>

<pre><code>package model;

public class MyObject {

    private String name;

    private String field;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

}
</code></pre>

<p>Any help would be greatly appreciated. I tried it without the JSON.stringify and it doesn't work either.</p>