@RequestMapping(value = "/foreign_updata.html") public String updataforeign( foreigner foreign, HttpServletRequest request, HttpServletResponse response) throws IOException { // 获取session中保存的对象 User user = (User) Untils.getSessionP(request, "user"); foreignServices = (ForeignServices) springContextUtil.getBean("ForeignServices"); // 上传文件处理器 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; // 文件对象 MultipartFile pp_attachment = (CommonsMultipartFile) multipartRequest.getFile("pp_attachment"); MultipartFile ee_attachment = (CommonsMultipartFile) multipartRequest.getFile("ee_attachment"); String message = foreignServices.storeUpdata(foreign, pp_attachment, ee_attachment, user); response.setContentType("text/Xml;charset=utf-8"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("pragma", "no-cache"); response.setDateHeader("expires", 0); PrintWriter out = null; try { out = response.getWriter(); JSONObject object1 = new JSONObject(); object1.put("message", message); out.println(object1); } catch (IOException ex1) { ex1.printStackTrace(); } finally { out.close(); } return null; }
@RequestMapping(value = "/foreign_add.html") public String addforeign( foreigner foreign, @RequestParam MultipartFile pp_attachment, @RequestParam MultipartFile ee_attachment, HttpServletRequest request, Model model) throws IOException { // 获取session中保存的对象 User user = (User) Untils.getSessionP(request, "user"); foreignServices = (ForeignServices) springContextUtil.getBean("ForeignServices"); String massage = foreignServices.store(foreign, pp_attachment, ee_attachment, user); model.addAttribute("return_info", massage); return "/foreign/foreign_info"; }