[英]Why i am getting 406 not accepatble at client side status by the server and even my spring controller is not calling?
[英]Why i am getting 406 not acceptable response?
這是我的代碼
$.ajax({
url: "DataGridServlet.htm",
type: "GET",
traditional: true,
dataType: 'JSON',
cache: false,
contentType:"application/json",
success: function (response){
console.log(response);
}
});
});
當我向控制器發送請求時..每個都在工作,但是wnem返回JSONObject,我得到的狀態碼是406,這是不可接受的。
及以下的彈簧控制器代碼
@RequestMapping(value="/DataGridServlet.htm", method = RequestMethod.GET,produces="application/json",headers="Accept=*/*")
public @ResponseBody JSONObject getReturnData()
{
System.out.println("control came into conroller");
JSONObject dataObject=new JSONObject();
dataObject=jqTabsGridDataDao.getTabsData();
System.out.println("controller data"+dataObject);
return dataObject;
}
有人可以幫助我嗎?
更改
@RequestMapping(value="/DataGridServlet.htm", method = RequestMethod.GET,produces="application/json",headers="Accept=*/*")
至
@RequestMapping(value="/DataGridServlet.htm", method = RequestMethod.GET,produces="application/json",)
和這個
$.ajax({
url: "DataGridServlet.htm",
type: "GET",
traditional: true,
dataType: 'JSON',
cache: false,
contentType:"application/json",
success: function (response){
console.log(response);
}
});
});
至
$.ajax({
url: 'DataGridServlet.htm',
type: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
success: function(result) {
alert(result + " result ");
},
error: function(resError) {
//alert(resError + " Error ");
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.