后台用这种方式返回数据到ftl,有问题吗,list为什么取不到值

@RequestMapping(value = "/project/p_list.do", method={RequestMethod.POST, RequestMethod.GET})
public ModelAndView login(HttpServletRequest request, HttpServletResponse response) throws Exception {
ModelAndView mv = new ModelAndView("test2");

    String token = request.getParameter("token");
    String page = request.getParameter("page");
    String upStatu=request.getParameter("upStatu");
    String statu=request.getParameter("statu");

    String loginUrl = "http://10.0.2.14:8080/zfs_pg/project/p_list.do?";
    String url = loginUrl + "token="+ token ;//+ "&page=" + page + "&upStatu=" + upStatu + "&statu=" + statu; 

    String result = null;
    try {
        result = HttpUtils.URLPost(url);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace(); 
    }
    System.out.println(result);

    JSONObject  jsonObject = new JSONObject(result);
    int ret = jsonObject.getInt("ret");
    List<Project> pList = new ArrayList<Project>();
    if(ret==0){ 
        JSONObject  jsonObject2 = jsonObject.getJSONObject("data");
        JSONArray plist = jsonObject2.getJSONArray("plist"); 

        for (int i = 0; i < plist.length(); i++) {
            JSONObject pC = plist.getJSONObject(i);
            int pid = pC.getInt("pid");
            String title = pC.getString("title");
            String content = pC.getString("content");
            String type = pC.getString("type");
            String pTime = pC.getString("pTime");
            String endTime = pC.getString("endTime");
            String uName = pC.getString("uName");
            Project pc = new Project();
            pc.setPid(pid);
            pc.setContent(content);
            pc.setTitle(title);
            //pc.setpTime(pTime);
            pList.add(pc);
        }           
    }else{
        String msg = jsonObject.getString("msg");
    }



    mv.addObject("plist", pList);
    return mv;

}

2个回答

freemarker取数据时,先判断是否为空。

在后台输出测试一下

hanhx1993
匿名用户123 后台数据获取到了,就是对freemarker不熟,不知道这么传值可以吗,怎么取值
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐