LEATH
1234567891011//点击button触发事件发送ajax请求function show(){ //发送请求的url 这是附带的参数 $.post("${ctxPath}/add",{"goodsId":goodsId},function (data){ if(data.sign=="success"){ alert("添加成功"); }else { alert(data.message); } },"json");} 1234567891011121314151617 @RequestMapping(value = "add")//请求地址 @ResponseBody //返回json要加这个注解 具体自行百度 public Map<String, Object> add(HttpServletRequest request){ //获取ajax传过来的参数 String value = request.getParameter("goodsId"); Map<String, Object> map = new HashMap<String, Object>(); //这写业务流程 if(判断是否添加成功){ //成功 map.put("sign", "success"); }else{ //失败 map.put("sign", "error"); map.put("message", "添加失败!"); } return map; }