java - How to avoid HTTP Status 415 when sending ajax request to the server? -


i have ajax call should return json document

function getdata() {     $.ajax({         url: '/x',         type: 'get',         data: "json",         success: function (data) {             // code omitted         }     }); } 

my server side simple.

@requestmapping(value = "/x", method = get, produces = "application/json") public @responsebody list<employee> get() {     return employeeservice.getemployees(); } 

but request can't controller. error is:

http status 415 - server refused request because request entity in format not supported requested resource requested method. 

how can fix it?

add @consumes("text/html") before code in server side,

@consumes("text/html") @requestmapping(value = "/x", method = get, produces = "application/json") public @responsebody list<employee> get() {     return employeeservice.getemployees(); } 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -