日期:2014-05-17  浏览次数:20807 次

分页问题 点击下一页不跳转问题!!!
这是后台查询,初始化也是这个方法,点击下一页也是这个方法

Java code

/**
     * 跳转到用户查询
     * 
     * @return
     */
    @Action(value = "/manager/toUserList", results = { @Result(name = "SUCCESS",type="freemarker", location = "/WEB-INF/manager/user/userList1.ftl") })
    public String toUserList() {        
        try {    
        
            PageResults<ManagerUserEntity> result = this.managerUserService.findTManagerUserByPage(user, getPageBean());
            this.setUserList(result);
            
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();            
            this.setMsg(URLUtils.encode(e.getMessage(), "UTF-8"));
            return "ERROR";
        }
        
        return "SUCCESS";
    }






前台我是用freemarket写的,看看执行下一页的代码


<#if ipage lt totalpage>
<a class="a" href="?page=${ipage + 1}${requestParams}">下一页</a>
<#else>
<span class="a">下一页</span>
</#if>


我调试了一下后台dao里面

Integer start = bean.getPageSize() * (bean.getPageIndex() - 1);
Integer end = bean.getPageSize() * bean.getPageIndex();

pageindex竟然是1 应该是2啊
跪求大神吧

------解决方案--------------------

下面是我写的分页,运行没有问题,楼主看下吧

Java code


public class Serch extends ActionSupport
{
   private  String  bid;
   private  String  bname;
   private  int    number;
   private int k;//储存最大页面数
   private int pageNow=1; //页码数,初始为1
   private int pageSize = 5 ; //页面行数 
   private int intRowCount;//总行数
   private int intPageCount;//总页数
   private int lastPage;
   private int p=1;


.....set/get;
public String execute() throws Exception 
{
    List list=new List();
    java.util.List L=new  ArrayList();
    L=list.list();
    intRowCount=L.size();
    System.out.println("链表的长度:"+L.size());
    if(L.size()%pageSize==0) //判断分多少页
          this.lastPage=L.size()/pageSize;
    else
        this.lastPage=L.size()/pageSize+1;
    
    this.setIntPageCount(this.lastPage);//存入总页数
    
    if(this.pageNow<1)//如果当前页码是第一页在点第一页的时候也跳转到第一页
        this.pageNow=1;
    if(this.pageNow>this.lastPage)//同理只不过是最后一页
        this.pageNow=this.lastPage;
    /*
     * 
     * 假设取其中20-25条
     * 
     * 
     * 
     */
  int startIndex=(this.pageNow-1)*pageSize;//截止条目开始,第20条
  int endIndex=startIndex+pageSize;//截止条目结束     第25条
  
  if(endIndex>=L.size())
      endIndex=L.size();
 
  L= L.subList(startIndex, endIndex);
  System.out.println("执行");
  
    ActionContext.getContext().put("list", L);
    return  "success";
}
@Override
public void validate() {
    // TODO Auto-generated method stub
    super.validate();
}


}
前台显示:


共<s:property value="intRowCount"/>记录&nbsp;&nbsp;
共<s:property value="intPageCount"/>页&nbsp;&nbsp;
        第<s:property value="pageNow"/>页&nbsp;&nbsp;
 <s:url action="Serch.action" id="url">
                <s:param name="pageNow">
                    <s:property value="1" />
                </s:param>
            </s:url>
  <s:a href="%{url}">首页</s:a>    &nbsp;&nbsp;
       
       <s:url action="Serch.action" id="url">
                <s:param name="pageNow">
                    <s:property value="%{pageNow-1}" />
                </s:param>
            </s:url>
  <s:a href="%{url}">上一页</s:a>    &nbsp;&nbsp;


 <s:url action="Serch.action&