这里用的是struts,要用的jar包:fastjson-1.0.4.jar
struts配置
type="com.allinpay.ets.bm.action.mchtManage.ActionTest"
<forward name="ok" path="/jsp/param/ok.jsp" />
jsp中的js:
异步请求的页面:
function test(){
$.ajax({
type: "POST",
contentType:"application/json",
url:"/oss/param/test.do",
data:"{}",
dataType:'json',
success:function (response){
alert(response.info);
}
});
}
请求后返回的页面,里面只要下面的:
${json}
ActionTest:
Map<String,Object> map = new HashMap<String,Object>(); map.put("info","testData"); request.setAttribute("json",JSON.toJSONString(map)); return actionMapping.findForward("ok");
原文链接:https://www.f2er.com/ajax/166866.html