前端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); } });
后端代码:
@RequestMapping(value = "/getDatas.do", method = RequestMethod.GET) @ResponseBody public Result getDatas(HttpServletRequest request, @RequestParam(defaultValue = "") String devId) { Result result = new Result(); result.setMsg("查询成功:" + devId); return result; }
改变的地方:
public Result getDatas(HttpServletRequest request, @RequestParam(defaultValue = "") String devId
)