• Now all data be ready for publish, We had made our blog alive now. Haha.

  • These days CCP GFW blocked all the IPs from US and when I switch my IP in google Cloud, the disk data cannot be restore again. I have to restart my blog totally, Now the website is still building…

Spring JSON request getting 406 (not Acceptable)- Stack Overflow

Java PingBook 1 months ago (10-23) 15 0


this is my javascript:

function getWeather() {
$.getJSON(‘getTemperature/’ + $(‘.data option:selected’).val(), null, function(data) {

this is my controller:

@RequestMapping(value=”/getTemperature/{id}”, headers=”Accept=*/*”, method = RequestMethod.GET)
public Weather getTemparature(@PathVariable(“id”) Integer id){
Weather weather = weatherService.getCurrentWeather(id);
return weather;


Getting this error:

GET http://localhost:8080/web/getTemperature/2 406 (Not Acceptable)


Response Headers

Server Apache-Coyote/1.1
Content-Type text/html;charset=utf-8
Content-Length 1070
Date Sun, 18 Sep 2011 17:00:35 GMT

Request Headers

Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept application/json, text/javascript, */*; q=0.01
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
X-Requested-With XMLHttpRequest
Referer http://localhost:8080/web/weather

Interesting note:

I get 406 error, but the hibernate query works meanwhile.
This is what tomcat log says, everytime when I change selection in dropbox:

select weather0_.ID as ID0_0_, weather0_.CITY_ID as CITY2_0_0_, weather0_.DATE as DATE0_0_, weather0_.TEMP as TEMP0_0_ from WEATHER weather0_ where weather0_.ID=?

What could the problem be? There were two similar questions in SO before, I tried all the accepted hints there, but they did not work I guess…

Any suggestions? Feel free to ask questions…


406 Not Acceptable

The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

So, your request accept header is application/json and your controller is not able to return that. This happens when the correct HTTPMessageConverter can not be found to satisfy the @ResponseBody annotated return value. HTTPMessageConverter are automatically registered when you use the , given certain 3-d party libraries in the classpath.

Either you don’t have the correct Jackson library in your classpath, or you haven’t used the

I successfully replicated your scenario and it worked fine using these two libraries and no headers=”Accept=*/*” directive.


Copyright from PingBook Blog, If not specified, they are original. This site uses BY-NC-SAProtocol authenticated.
For reprinting, please indicate the link of the original text:Spring JSON request getting 406 (not Acceptable)- Stack Overflow
LIKE (0)
We create, We sharing! Tag every value data your sharing
Submit comments
Cancel comments
emoji picture bold strikethrough center italic check in

Hi,you need to provide your name and email adress!

  • Name (Required)
  • Email (Required)
  • Website