Spring2.5.4根据ajax请求返回一个整数
我正在从事一个Spring2.5.4项目,在这个项目中,我需要得到一个ajax响应,在ajax请求中返回一个整数值。有什么办法我可以做到吗 现在,我相信所有ajax调用要么返回一个页面,要么返回页面的一部分 我在原型的ajax请求中使用的示例代码如下:Spring2.5.4根据ajax请求返回一个整数,ajax,spring,spring-mvc,prototypejs,Ajax,Spring,Spring Mvc,Prototypejs,我正在从事一个Spring2.5.4项目,在这个项目中,我需要得到一个ajax响应,在ajax请求中返回一个整数值。有什么办法我可以做到吗 现在,我相信所有ajax调用要么返回一个页面,要么返回页面的一部分 我在原型的ajax请求中使用的示例代码如下: var ajaxSourceTable = new Ajax.Request( '../fetch/timeout.html?ajax=true', { method:'post', parameters:{
var ajaxSourceTable = new Ajax.Request(
'../fetch/timeout.html?ajax=true',
{ method:'post',
parameters:{},
onSuccess:function(t){
/*alert time out here*/
alert(t.responseText);
},
onFailure:function(t){
alert("Request failed ! Please report the issue : "+t.responseText);
}
}
);
../fetch/timeout.html?ajax=true必须返回单个值。您应该为返回text/plain或application/json以及响应正文中的数据的控制器编写一个控制器。您能提供一些指向某个示例或代码片段的指针吗:我自己也弄不清楚。谢谢您的时间。是的,请您自己熟悉。不要忘记将响应类型设置为application/json。这将使您能够使用原型t.responseJson直接检索对象。一般来说,google for spring 2.5控制器返回json。