使用freemarker前端分页,报错:

FreeMarker template error: The following has evaluated to null or missing

后端直接赋值:

    List<Student> stu=new ArrayList<Student>();
        Student s1=null;
        for(int i=1;i<46;i++){
            s1=new Student();
            s1.setAge(i+10);
            s1.setId(i+"100");
            s1.setName("ww"+i);
            stu.add(s1);
        }        
        
        Page<Student > page = new PageImpl(stu,pageable,45);
        model.addAttribute("content", page);
        return new ModelAndView("/Page1",model);

分析可能原因:

1. Student列表中的对象的getter method不是public?

2. student类是否public类?

3. 引用的值是否正确?

经验证都没有问题。

后面发现和文件引入的位置有关,pagination.ftl应该是宏定义,应该放到文件的开头声明(目前放到文件的末尾导致)。

 

posted on 2015-09-08 19:46  一天不进步,就是退步  阅读(1796)  评论(0编辑  收藏  举报