如何使用struts 1在jsp中添加分页索引

时间:2015-04-13 09:26:24

标签: java javascript html css jsp

我在每个页面上都有分页但序列号(S / N)从1到10开始像这样。在第2页。我希望(S / N)从11到20,依此类推。但是在第2页我也得到(S / N)从1到10只。请帮助我解决这个问题。      这是我的jsp页面。      <%          int startIndex = 0;          int totalsize = 0;

     Collection OBList =   (Collection)request.getAttribute("request.OBAList");
    if (OBList != null && OBList.size() > 0) 
    {
      pageContext.setAttribute("OBList",OBList);
    }
    if(request.getAttribute("request.startIndex")!=null)
 startIndex=Integer.parseInt(request.getAttribute("request.startIndex").toString());
      int current_page=startIndex/10;
      if(startIndex == 10)
      {
          startIndex=startIndex+current_page;
      }
   %>

      <logic:present name="OBList">
      <% int count = 0;%>
      <logic:iterate id="OB"       name="OBList"type="com.integrosys.course.app.test.bus.OBA" scope="page">
      <tr class="<%=count++%2==0?"even":"odd"%>">
      <td class="index" id="cn"><%=count%></td>
      <td id="name"><%=OB.getName()%></td>
      <td id="country"><%=AProxy.getCountryName(OB.getCountry()) %></td>
      <td style="text-align:center"><select name="select3"   onChange="JumpOnSelectactive(this, '<%=OB.getName()%>')">
       <option selected="selected" >Please Select</option>
       <option value="edit">Edit</option>
       <option value="view">View</option>
       <option value="delete">Delete</option>
        </select>
       </td>
       <td><html:checkbox property="checkboxes" styleId="ck" value="      <%=OB.getName()%>" ></html:checkbox></td>
        </tr>

     <integro:pageindex 
            pageIndex='<%=new            PageIndex(startIndex,AProxy.getMaxRecordPage(),AProxy.getAll().size())%>'
            url='<%="A.do?event=list&startIndex="%>'
            submitFlag="<%=new Boolean(false)%>"/>

             this is my command java class
             String startIndex="0";

             try {

                     Object obStartIndex = map.get("startIndex");
                        if(obStartIndex!=null)
                        {
                           startIndex= obStartIndex.toString();
                         }
                        c=aProxy.getAll();

                       //total=c.size();
                       Collections.sort(((List<OBA>)c),new Comparator<OBA>()                              {

            @Override
            public int compare(OBA o1, OBA o2) {
                // TODO Auto-generated method stub
                return o1.getName().compareTo(o2.getName());
            }
            });
            c=  ((List<OBA>)c).subList(Integer.parseInt(startIndex),Math.min(Integer.parseInt(st  artIndex)+ aProxy.getMaxRecordPage(), c.size()) );

0 个答案:

没有答案