JSP分组分页

来源:互联网 发布:来电管家软件 编辑:程序博客网 时间:2024/05/18 03:08

<%@ page contentType="text/html; charset=utf-8" language="java" %>
<%@page import="com.pp.ee.util.AnalysisPageXml"%>
<%@page import="com.pp.page.tagsstips.AllMainTagsBean"%>
<%@page import="com.ppaxtie.page.tagsstips.ProductHeadTagsBean"%>
<%@page import="com.pp.ee.directory.products.CompanyBean"%>
<%@page import="com.pp.ee.directory.company.CompanyService"%>
<%@page import="java.util.*"%>
<%
    CompanyService CompanyService1=new CompanyService();
    String userType="u2";
    int currPage=Integer.parseInt((request.getParameter("currPage")==null)? "1" :request.getParameter("currPage"));//定义分页的默认页为第一页
 int pageSize=2;//每页显示多少行
 int rowCount=CompanyService1.getAllNum(userType);//一共有多少记录
    int pageCount=(rowCount%pageSize==0)? (rowCount/pageSize):((rowCount/pageSize)+1);//共有多少页
   
  
   
   
    String language=(request.getParameter("language")==null)?"ch":request.getParameter("language");
    AnalysisPageXml AnalysisPageXml=new AnalysisPageXml();
    AllMainTagsBean AllMainTagsBean=(AllMainTagsBean)AnalysisPageXml.getPageTips("AllMainTags",language);
    ProductHeadTagsBean ProductHeadTagsBean=(ProductHeadTagsBean)AnalysisPageXml.getPageTips("producthead",language);
   
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=AllMainTagsBean.getInternationalDevelopmentDirectory()%></title>
<meta name="generator" content="maxtie" />
<meta name="description" content="<%=AllMainTagsBean.getDescription() %>"/>
<meta name="keywords" content="<%=AllMainTagsBean.getTitlekeyword() %>"/>
<link rel="stylesheet" type="text/css" href="freindlyLInk/css/cooperator.css" />
<script>

function serchPage(){
       var tt=document.getElementById("currPage").value;
       if(isNaN(tt))
     {
      alert("对不起,请您输入数字......");
      document.getElementById("currPage").value="";
      return;   
     }
     
         var page=parseInt(tt);
         if(page<=<%=pageCount%>){
                  document.form.submit();
                   
             }else
             {
                       alert("对不起,您输入的数字过大......");
                  document.getElementById("currPage").value="";
                  return; 
            
            
             }
         
     }
</script>
</head>
<body
<table border="0" cellpadding="0" cellspacing="0" align="center"   class="SubNav">
  <tr>
 
    </tr>
</table>
<div id="title">
<h3><%=AllMainTagsBean.getVipMembers()%></h3></div>
<table id="topTable" cellpadding="0" cellspacing="0">
<%
    CompanyService CompanyService=new CompanyService();
    List list=CompanyService.getAll(userType,language,currPage,pageSize);
    for(int i=0;i<list.size();i++){
    CompanyBean CompanyBean=(CompanyBean)list.get(i);
   
     if(i%2==0){
       %>
           <tr><td><img src="<%=request.getContextPath()%>/images<%=CompanyBean.getLogPath()%>" alt="logo" width="166" height="54" />
           <div><a href="../dircetory/company/Comapny_data/<%=CompanyBean.getCompanyid()%>_<%=language %>.html"><%=CompanyBean.getCompanyname() %></a>
           <p><%=AllMainTagsBean.getRegion() %>:<%=CompanyBean.getCompanystate() %></p>
           <p><%=AllMainTagsBean.getIndustry() %>:<%=CompanyBean.getCompanyindustry() %></p>
           </div>
           </td>
      
        <%
     }else{
        %>
           <td><img src="<%=request.getContextPath()%>/images<%=CompanyBean.getLogPath()%>" alt="logo" width="166" height="54" />
           <div><a href="../dircetory/company/Comapny_data/<%=CompanyBean.getCompanyid()%>_<%=language %>.html"><%=CompanyBean.getCompanyname() %></a>
           <p><%=AllMainTagsBean.getRegion() %>:<%=CompanyBean.getCompanystate() %></p>
           <p><%=AllMainTagsBean.getIndustry() %>:<%=CompanyBean.getCompanyindustry() %></p>
           </div>
           </td>
           </tr>
        <%
    
     }
    }

 %>
 

</table>
<table width="800"  height="17" border="0" cellspacing="0" cellpadding="0" style=" margin:5px auto;">
  <tr>
    <td  align="center" width="550" valign="bottom"><a href="zhou.jsp?currPage=1&language=<%=language%>"><img src="ChangePage/First_Btn.jpg" alt=" " width="49" height="17" style="margin-right:5px;"/></a>
    <%
     int GcurrPage=0;
  int GpageSize=5;//每列显示5页
     int GpageCount=(pageCount%GpageSize==0)? (pageCount/GpageSize):((pageCount/GpageSize)+1);//共有多少列
   
   
     %>
    <%
         if(currPage>1){
         %>
          <a href="zhou.jsp?currPage=<%=currPage-1%>&language=<%=language%>"><img src="ChangePage/Previous_Btn.jpg" alt=" " width="53" height="17" style="margin-right:5px;"/></a>
         <%
     
      }%>
        <%
         for(int i=1;i<=GpageCount;i++){
              if((i-1)*GpageSize<currPage&&currPage<=i*GpageSize){
                    GcurrPage=i;
                   
              if(GcurrPage>1){
             
                           %>
                             <a href="zhou.jsp?currPage=<%=(GcurrPage-1)*GpageSize%>&language=<%=language %>">...</a>
                           <%  
              }
                    if(i*GpageSize<pageCount){
                      for(int j=(i-1)*GpageSize+1;j<=i*GpageSize;j++){
                        
                          %>
                             <a id="b<%=j%>" href="zhou.jsp?currPage=<%=j%>&language=<%=language %>"><%=j%></a>
                           <%
                         if(j==currPage){%>
                   <script>
                      document.getElementById("b<%=j%>").className="hoverpage";
                   </script>
                        <%}
                     }
              }else{
                     for(int j=(i-1)*GpageSize+1;j<=pageCount;j++){
                         
                         %>
                             <a id="b<%=j%>" href="zhou.jsp?currPage=<%=j%>&language=<%=language %>"><%=j%></a>
                         <% 
                         if(j==currPage){%>
                   <script>
                      document.getElementById("b<%=j%>").className="hoverpage";
                   </script>
                        <%}
                     }
             
             
              }
              if(GcurrPage<GpageCount){%>
                  <a href="zhou.jsp?currPage=<%=GcurrPage*GpageSize+1%>&language=<%=language %>">...</a>
             
             <% }
             }
         }    
     %>
        <%if(currPage<pageCount){  %>
          <a href="zhou.jsp?currPage=<%=currPage+1%>&language=<%=language%>"><img src="ChangePage/Next_Btn.jpg" alt=" " width="53" height="17" style="margin-right:5px;"/></a>
         <% }%>
   
  
    <a href="zhou.jsp?currPage=<%=pageCount%>&language=<%=language%>" ><img src="ChangePage/Last_Btn.jpg" alt=" " width="54" height="17" style="margin-right:5px;"/></a>
 
   </td>
       <td valign="top" style="font-size:14px; color:red;">[ <%= currPage%>/<%=pageCount%> ]   </td>
   <td>
   <form name="form" action="zhou.jsp" method="post">
    <input type="text" id="currPage" name="currPage" size="1" style="width:20px; height:15px;float:left;margin-right:5px;"/><img src="ChangePage/Go_Btn.jpg"  onclick="serchPage()" style="float:left;"/>

    </form>
   
   </td>
  </tr>
</table>
</body>
</html>

原创粉丝点击