/** * 保存操作 * * @param request * @param response * @throws IOException */ @RequestMapping(value = "saveProduct.do", method = RequestMethod.POST) public void saveProduct(HttpServletRequest request, HttpServletResponse response) throws IOException { boolean isTrue = true; String msg = "操作成功"; try { // 从上下文获取当前登录用户信息 SessionUser sessioUser = (SessionUser) request.getSession().getAttribute(SessionConstant.USER); if (sessioUser != null && StringUtils.isNotBlank(sessioUser.getUserId())) { Product po = this.getFormParameter(request, response); po.setSupId(sessioUser.getUserId()); // 保存 this.productService.addOrModifyProduct(po); } } catch (Exception e) { e.printStackTrace(); isTrue = false; msg = "操作失败"; } JSONObject jobj = new JSONObject(); jobj.put("result", isTrue); jobj.put("msg", msg); AjaxUtil.writeResult(response, jobj); }
//发布产品
<script> $(function(){ $("#savepro_and_next").unbind("click").on("click",function(){ var formData = $("#rqFrom").serializeArray(); var fmdata = {}; $.each(formData, function() { var name = this.name; fmdata[name] = this.value; }); fmdata.userId = "user_id_004"; $.post("${contextPath}/wechat/saveProduct.do", fmdata, function(data) { if (data.result) { //alert("保存成功"); } else { alert(data.msg); //跳转到登陆界面 } }); }); }) </script> 1
Ouyangan 2016-04-24 16:39:20 +08:00 via Android
排版
|
2
jsonline 2016-04-24 17:18:28 +08:00 via Android
log
|