我正在尝试从进行 ajax 调用的 spring mvc 控制器返回一个 Map,但我没有得到正确的响应。
我在我的配置文件中使用了 mvc 注释标记,并且还在我的库中包含了 jackson jar 文件。
我的要求是将 Map 返回到我的 Ajax 调用成功,以便我可以修改 html 中的表行。
控制器代码:
@RequestMapping(value="/pricingrecall.do", method=RequestMethod.POST)
@ResponseBody
public Map<Integer,String> pricingUpdate(@RequestParam(value = "opp_Code", required = false) String opp_Code,
@RequestParam(value = "ref_id", required = false) String ref_id,
ModelMap model,
HttpServletRequest request, HttpServletResponse response) throws SQLException, Exception{
String User="fe0777";
List<CrossListViewBean>updatedRow = new ArrayList<CrossListViewBean>();
//String message="";
logger.info(methodLocation+"|"+"Calling pricing recall ....");
Map<String, Object> result = new HashMap<String, Object>();
updatedRow=crossCampService.getupdatedrowListview(opp_Code, ref_id, user);
Map<Integer,String> lbean= new HashMap<Integer,String>();
lbean=crossCampService.getUpdatedDataPosition(updatedRow.get(0));
return lbean;
}
来自阿贾克斯的电话:
jQuery.ajax( {
url : '/Web/pricingrecall.do',
type: "POST",
cache : false,
timeout : 60000,
data : {
opp_Code :CampId ,
ref_id : index
},
success : function(result, textStatus, request) {
if(result)
{
alert(result);
//jQuery(".note"+index).html(data);
}else
{
alert("The user session has timed out. Please log back in to the service.");
window.location.replace("logout.do");
}
},
error : function(request, textStatus, errorThrown) {
alert("The system has encountered an unexpected error or is currently unavailable. Please contact the support number above if you have any questions.");
}
});
在 ajax 成功中,我总是遇到错误,它被转移到错误字符串中。我如何在ajax成功中从MAP获取Json
请帮忙