逻辑是这样的:根据姓名,年龄找出符合条件的计录,并分页显示。算是多条件分页查询了。在tomcat中运行System.out.println("listcount:"+total);打印为0,jsp中显示不到数据(数据库中有符合条件的记录2条),请问哪里出问题呢!!代码如下:
分页的实现:public PageModel findHuamanfileByExample(int page,int pagesize,Human_file human_file){
System.out.println("id:"+human_file.getId());
System.out.println("age:"+human_file.getAge());
System.out.println("name:"+human_file.getName());
Session session=this.getSession();
long total=((Number)session.createCriteria(Human_file.class).add(Example.create(human_file)).setProjection(Projections.rowCount()).uniqueResult()).intValue();

List datas=session.createCriteria(Human_file.class).add(Example.create(human_file)).setFirstResult((page-1)*pagesize).setMaxResults(pagesize).list();

System.out.println("listcount:"+total);
PageModel pm=new PageModel();
pm.setTotal(total);
pm.setDatas(datas);
return pm;
}
pagemodel类:public class PageModel {
/*
 * 记录总数
 */
private long total;
/*
 * 当前页的记录集合
 */
private List datas; public long getTotal() {
return total;
} public void setTotal(long total) {
this.total = total;
} public List getDatas() {
return datas;
} public void setDatas(List datas) {
this.datas = datas;
}}
structs中的actionpublic ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
MajorChangeIndexForm mf=(MajorChangeIndexForm)form;
int page = 0; 
String offsetStr = request.getParameter("pager.offset");
System.out.println("offset:"+offsetStr);
        try {   
          
            if(offsetStr == null){    
                //若offset为null则是第一次访问,所以显示第一页    
             page = 1;    
                }else{    
                //反之,则按照传递来的页数来分    
                 page = Integer.parseInt(offsetStr)/10;    
                }   
        } catch (Exception e) {   
        }    
      //加入数据
 Human_file human_file=new Human_file();
 PageModel pm=new PageModel();
 if(request.getParameter("mode").equals("exact")){
//human_file.setId(mf.getDananhao());
pm = majorChange.findHuamanfileByID(mf.getDananhao());
}else if(request.getParameter("mode").equals("fuzzy")){
human_file.setId(null);
human_file.setBonus_amount(null);
human_file.setTraining_amount(null);
human_file.setFile_chang_amount(null);
human_file.setAge(mf.getAge());
//human_file.setName(null);
human_file.setName(mf.getEname());
Organize org=new Organize();
org.setOrg_name(mf.getOrg());
human_file.setOrganize(org);
Zhicheng zhicheng=new Zhicheng();
zhicheng.setName(mf.getZhicheng());
human_file.setZhicheng(zhicheng);
 //按照每页显示10条   
        pm = majorChange.findHuamanfileByExample(page, 10, human_file); 
}    
        
        request.getSession().setAttribute("pm", pm);   
           
        return mapping.findForward("majorChangehumanlist"); 
}