http 406 java_java – Spring JSON请求获取406(不可接受)

这是我的javascript:

function getWeather() {

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

alert('Success');

});

}

这是我的控制器:

@RequestMapping(value="/getTemperature/{id}", headers="Accept=*/*", method = RequestMethod.GET)

@ResponseBody

public Weather getTemparature(@PathVariable("id") Integer id){

Weather weather = weatherService.getCurrentWeather(id);

return weather;

}

spring-servlet.xml

获取此错误:

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

标题:

响应头

Server Apache-Coyote/1.1

Content-Type text/html;charset=utf-8

Content-Length 1070

Date Sun, 18 Sep 2011 17:00:35 GMT

请求标头

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

Cookie JSESSIONID=7D27FAC18050ED84B58DAFB0A51CB7E4

有趣的是:

我得到406错误,但休眠查询工作同时。

这是tomcat日志说,每当我改变选择在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=?

问题是什么?在SO之前有两个类似的问题,我尝试了所有接受的提示,但他们没有工作我猜…

有什么建议么?随意问的问题…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值