一个关于表单数据无法写入到数据库的问题,特来求助。。。

2016-04-24 15:25:04 +08:00
 sdenbi

/** * 保存操作 * * @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>
1350 次点击
所在节点    问与答
2 条回复
Ouyangan
2016-04-24 16:39:20 +08:00
排版
jsonline
2016-04-24 17:18:28 +08:00
log

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/274053

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX