/* * type: title , content */ @RequestMapping(value = "/update/{docid}/{type}", method = RequestMethod.POST) @ResponseBody public String update( @PathVariable long docid, @RequestParam("post-text") String content, @PathVariable String type, HttpServletRequest request, HttpServletResponse response) throws Exception { String retValue = ""; // request.setCharacterEncoding("utf8"); // response.setCharacterEncoding("utf8"); // response.setContentType("application/json;charset=UTF-8"); HttpSession session = request.getSession(); User user = (User) session.getAttribute("loginuser"); if (user == null) { retValue = "{\"success\":\"false\",\"msg\":\"请登录。\"}"; return retValue; } // String content =post-text;// request.getParameter("post-text"); if (StringUtils.isEmpty(content)) { return retValue = "{\"success\":\"false\",\"msg\":\"提交内容不能为空。\"}"; } Map map = new HashMap(); map.put("docid", docid); if ("title".equals(type)) { map.put("title", StringEscapeUtils.escapeHtml4(content)); } else if ("content".equals(type)) { map.put("content", content); } try { docService.update(map); retValue = "{\"success\":\"true\",\"msg\":\"提交成功!\"}"; return retValue; } catch (Exception e) { log.error(e.getMessage()); retValue = "{\"success\":\"false\",\"msg\":\"保存失败,稍后再提交。\"}"; return retValue; } }