1. 程式人生 > >Js中不能獲取後端通過ModelAndView中的map資料?

Js中不能獲取後端通過ModelAndView中的map資料?

public ModelAndView viewAll(@RequestParam(value = "XH") String XH,@RequestParam(value = "co") String co) {

    ModelAndView mv=new ModelAndView();
mv.addObject("co",co);
ZHGL_JBXX_XSJBXX jbxx = new ZHGL_JBXX_XSJBXX();
ZHGL_JBXX_XSLXFSXX lxfs = new ZHGL_JBXX_XSLXFSXX();
ZHGL_JBXX_XSRXXX xsrx = new ZHGL_JBXX_XSRXXX();
List<Map> gzjl = new ArrayList<Map>(); List<Map> jtcy = new ArrayList<Map>(); List<Map> jyjl = new ArrayList<Map>(); List<Map> xwzs = new ArrayList<Map>(); List<Map> xwjl = new ArrayList<Map>(); List<Map> yynl = new ArrayList<Map>();
List<Map> shsj = new ArrayList<Map>(); JSONObject ssxx = new JSONObject();//學生宿舍資訊 JSONObject qt = new JSONObject();//其他資訊 現在有班主任和輔導員姓名 try { jbxx = jbxxService.queryJbxx(XH); lxfs = jbxxService.queryLxfs(XH); System.out.println(XH); System.out.println(lxfs.toString()); xsrx = jbxxService
.queryXsrx(XH); gzjl = jbxxService.queryGzjl(XH); jtcy = jbxxService.queryJtcy(XH); jyjl = jbxxService.queryJyjl(XH); xwzs = jbxxService.queryXwzs(XH); xwjl = jbxxService.queryXwjl(XH); yynl = jbxxService.queryYynl(XH); shsj = jbxxService.queryShsj(XH); ssxx = jbxxService.queryXsSsxx(XH); qt = jbxxService.queryXsfdyAndBzr(XH); mv.addObject("jbxxJson",JSONObject.fromObject(jbxx));//將map轉化為json mv.addObject("xsrxJson",JSONObject.fromObject(xsrx)); JSONObject xh=new JSONObject(); xh.put("XH", XH); mv.addObject("XH",xh.toString());// } catch (Exception e) { e.printStackTrace(); } mv.addObject("jbxx",jbxx);//基本資訊 mv.addObject("lxfs",lxfs);//聯絡方式 mv.addObject("xsrx",xsrx);//入學資訊 mv.addObject("gzjl",gzjl);//工作經歷 mv.addObject("jtcy",jtcy);//家庭成員 mv.addObject("jyjl",jyjl);//教育經歷 mv.addObject("xwzs",xwzs);//校外證書 mv.addObject("xwjl",xwjl);//校外經歷 mv.addObject("yynl",yynl);//語言能力 mv.addObject("shsj",shsj);//社會實踐 mv.addObject("ssxx",ssxx);//宿舍資訊 mv.addObject("qt",qt);//輔導員班主任 mv.addObject("selectParams", getSurestream().getString("selectParams") ); System.out.println(getSurestream().getString("selectParams")); mv.setViewName("xsxx/jbxx/jbxxShowPage"); return mv;

}

jsp中可以通過var XH = ${jbxx.XH}來獲得,但js中就顯示未定義,可以現將jbxx這個map在後端先轉化成JSON,然後在後端獲取