標籤:splay lis 表單 提交 重點 time() ram dfa username
java傳jsp,代碼如下:
/**去修改頁面 * @param * @throws Exception */ @RequestMapping(value="/goEdit") public ModelAndView goEdit(Model model)throws Exception{ ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); //擷取樹形列表 JSONArray arr = JSONArray.fromObject(goodstypeService.listAllGoodstypenourl("0")); //此處填寫貨品類型第一級ID即可; String json = arr.toString(); json = json.replaceAll("GOODSTYPE_ID", "id").replaceAll("GOODSTYPE_PARENTID", "pId").replaceAll("GOODSTYPE_NAME", "name").replaceAll("subDict", "nodes").replaceAll("hasDict", "checked").replaceAll("treeurl", "url"); model.addAttribute("zTreeNodes", json); mv.addObject("GOODSTYPE_ID",0); //0代表根目錄 pd = receivingstandardService.findById(pd); //根據ID讀取 //根據收穫標準查詢所有的物料 List<PageData> wllist = receivingstandardmaterielService.findwlByRECEIVINGSTANDARD_ID(pd); //根據收穫標準查詢所有的工廠 List<PageData> gclist = receivingstandardfactoryService.findgcByRECEIVINGSTANDARD_ID(pd); mv.setViewName("cgxtpt/receivingstandard/receivingstandard_edit"); mv.addObject("msg", "edit"); mv.addObject("wllist", JSONArray.fromObject(wllist)); ---- 重點是這裡 mv.addObject("gclist", JSONArray.fromObject(gclist)); mv.addObject("pd", pd); return mv; }
前台jsp接收:
<input type="hidden" name="wllist" id="wllist" value=‘${wllist }‘> <input type="hidden" name="gclist" id="gclist" value=‘${gclist }‘>
form表單提交給java處理
/**修改 * @param * @throws Exception */ @RequestMapping(value="/edit") public ModelAndView edit() throws Exception{ logBefore(logger, Jurisdiction.getUsername()+"修改Receivingstandard"); if(!Jurisdiction.buttonJurisdiction(menuUrl, "edit")){return null;} //校正許可權 ModelAndView mv = this.getModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); receivingstandardService.edit(pd); /**操作記錄*/ Session session = Jurisdiction.getSession(); User user = (User) session.getAttribute(Const.SESSION_USER); PageData pd1 = new PageData(); pd1.put("RECEIVINGSTANDARDRECORD_ID", this.get32UUID()); pd1.put("RECEIVINGSTANDARD_ID", pd.getString("RECEIVINGSTANDARD_ID")); pd1.put("UPDATERID", user.getUSER_ID()); pd1.put("UPDATENAME", user.getNAME()); pd1.put("UPDATETIME", DateUtil.getTime()); receivingstandardrecordService.save(pd1); /**操作記錄結束*/ //根據收穫標準查詢所有的物料 List<PageData> wllist = receivingstandardmaterielService.findwlByRECEIVINGSTANDARD_ID(pd); //根據收穫標準查詢所有的工廠 List<PageData> gclist = receivingstandardfactoryService.findgcByRECEIVINGSTANDARD_ID(pd); //之前的物料 List<JSONObject> oldwllist = JSONArray.fromObject(pd.get("wllist")) ; ----------重點是這裡 //之前的工廠 List<JSONObject> oldgclist = JSONArray.fromObject(pd.get("gclist")) ; //之前的物料、工廠全部去掉 String msg2 = orderdataService.sendwmszjornojson(oldwllist, oldgclist,"N"); //現在的物料、工廠全部加上 String msg = orderdataService.sendwmszjorno(wllist, gclist,"Y"); System.out.println("物料。。。。。。。"+msg+msg2); mv.addObject("msg","success"); mv.setViewName("save_result"); return mv; }
兩種類型資料,一種是pagedata一種是JSONObject,後者擷取資料是:get();
list<PageData>傳jsp隱藏欄位,在傳回java