Spring MVC + Ajax JSON post
<p>I have a problem with send <code>JSON</code> to the <code>Controller</code>. I can't understand my problem.</p>

<p>So, url - <code>/notes/{username}/add</code></p>

<p><strong>Ajax</strong>:</p>

<pre><code>$.ajax({
        type: "POST",
        contentType : 'application/json; charset=utf-8',
        dataType : 'json',
        url: window.location.pathname,
        data: JSON.stringify({ title: $("#title").val(), text: $("#text").val() }),
        success : function() {
            $("#title").val("");
            $("#text").val("");
        }
    });
</code></pre>

<p><strong>Controller</strong>:</p>

<pre><code>@RequestMapping(value = "/{username}/add", method = POST)
    public void add(@RequestBody Note note) {
        noteRepository.add(new Note(UserSession.getUser(), note.getTitle(), note.getText()));
    }
</code></pre>

<p><strong>Note</strong>:</p>

<pre><code>public class Note {

    private String title;
    private String text;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}
</code></pre>

<p>Controller don't get request from ajax. I think, problem with url, but I can't why and what to do.</p>