日期:2014-05-16  浏览次数:20646 次

Struts2+jquery pagination插件使用
需求:实现无刷新分页
问题:现在页面永远都只有1页(首页和尾页都是1),第2页页码和后面的都没有出现,不知道是哪错了?分页的方法都没有执行到(没机会执行,看不见第2页和后面的页)。
var pageNo=0;
 $(function(){
 //initData(0);
 $("#Pagination").pagination(4 //总页数是4, { 
  
                   callback: pageselectCallback,  回调函数,没有机会执行
                   prev_text: '<< 上一页',  
                   next_text: '下一页 >>',  
                   items_per_page:10,  
                    num_display_entries:6,  
                    current_page: pageNo, 
                    num_edge_entries:2  
               });  
  function pageselectCallback(pageindex,jq) {  
           initData(pageindex);  //翻页的函数
       }  
       function initData(pageNo){
       $.ajax({
       type:"post",
      url:"go.action",
        async:false,
        data:"pageNo="+(pageNo+1)+"",
        success:function(data){
        if(data){
         var c=eval("("+data+")");
        for(var k=0;k<c.length;k++){
   
        $("#body").append("<tr><td>"+c[k].pid+"</td><td>"+c[k].mname+"</td></tr>");
        }
        }
        }
       });
       }
   
        
 });
    </script>
   <link rel="stylesheet" type="text/css" href="css/pagination.css">
 </head>
    <body>
   <table>
   <thead><tr><th>编号</th><th>姓名</th></tr></thead>
   <tbody id="body"></tbody>
   </table>
   <div id="Pagination" class="pagination"></div>
  </body>
</html>

@Override
public String execute() throws Exception {
Databean a=new Databean();
pageCount=a.count();
return SUCCESS;
}