前端JS代碼:前端
$.ajax({ type: "GET", url: getRootPath() + "/getDatas.do", contentType: 'application/json;charset=utf-8', //設置請求頭信息 data: "devId=" + devId, //必須是字符串 dataType: "json", success: function (res) { if (res.rtnCode == 0) { successToast(res.msg); } }, error: function (result) { errorToast(result.msg); } });
後端代碼:ajax
@RequestMapping(value = "/getDatas.do", method = RequestMethod.GET) @ResponseBody public Result getDatas(HttpServletRequest request) { Result result = new Result(); String devId= request.getParameter("devId"); result.setMsg("查詢成功:" + devId); return result; }