[英]406(Not acceptable) .trying to return object or integer from spring handling function using @Responsebody to ajax request
我在javascript中使用了以下代碼:
function submit(){
var form = $('#egform').serialize();
alert("before ajax");
$.post("testing.html", form, function(data, status) {
if (data==1) {
alert("Save successfull");
} else {
alert("Failed");
}
});
}
在我的控制器中:
@RequestMapping("testing.html")
public @ResponseBody Integer gettestvalue(HttpServletRequest request){
String a=request.getParameter("first");
System.out.println(a);
return 1;
}
但我沒有將返回的1傳遞給javascript函數。
我究竟做錯了什么?
確保pom.xml
具有以下依賴項:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
或者,如果您不使用Maven,只需確保將Jackson Mapper導入到您的項目中即可。
對我來說不是必需的,但您可能還需要核心依賴項 :
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.13</version>
</dependency>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.