我的后台是java , 前台页面是html , 用的是ajax来进行前后台交互
后台:
@ResponseBody
@RequestMapping("/count")
public void queryCount(HttpServletRequest request,HttpServletResponse response) throws IOException{
PrintWriter out = response.getWriter();
String id = request.getParameter("appVid");
int count = issueManageService.sum(id);
out.println(count);
}
要用Response输出值,request获取值
Servlet使用输出流来产生响应 PrintWriter out=res.getWriter();
向客户端发送字符数据。 out.println(“ ”);
前台:
$.ajax({
type:"post",
dataType : "text",//这里可能会有人写成"text/html",这样写就出不来了啦
data:rowData,
url:'IssueManage/count.do?appVid='+appVid,
loadingmask: true,// ajax请求时是否显示数据加载遮罩。
success : function(data) {
$("#count").val(data);
}
});
大概就是这样子吧