ajax代码:
$.ajax({
type:"POST",
url:"/test.do",
data:{},
beforeSend:function(){},
success: function(data){
var obj=eval("("+data+")");
if(obj.msg!=0){
$("#tongzhi-content").html(obj.msg);
$("#tongzhi").show();
}else{
$("#tongzhi").hide();
}
}
});
controller层代码:
@RequestMapping(value = "/test.do", method = RequestMethod.POST) private void doProcess(HttpServletRequest request , HttpServletResponse response) { StringBuffer json = new StringBuffer("{"); int msgNum = 10; json.append("'msg':'" + msgNum + "'"); json.append("}");//构造json数据格式 System.out.println("json数据:"+json); try { PrintWriter out = response.getWriter(); out.write(json.toString()); } catch (IOException e) { e.printStackTrace(); } }
请问为什么这么写请求不到后台对象的Controller?
参考:http://bbs.csdn.net/topics/390002329