list<PageData>传jsp隐藏域,在传回java
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();