java分页 jsp 结合实现

<%@page contentType="text/vnd.wap.wml;charset=UTF-8"%><%@page import="cn.sowap.DbClass"%><%@include file="inc/header.jsp"%><%
%>
<card id="welcome" title="&#x6211;&#x7684;&#x6D88;&#x606F;">
<p>
<%
String sid = request.getParameter("sid")!=null?request.getParameter("sid"):"";
String id = request.getParameter("id")!=null?request.getParameter("id"):"";
String op = request.getParameter("op")!=null?request.getParameter("op"):"";
List list = new ArrayList();
String pageNum = request.getParameter("page")!=null?request.getParameter("page"):"1";
list = new DbClass().msgList(sid);
HashMap hm = new HashMap();
int perPage = 5;
int total = list.size();
int tPage = total/perPage;

if (total%perPage > 0 )
tPage = total/perPage + 1;
int cpage = Integer.parseInt(pageNum);

boolean result = false;
if(op.equals("x5220"))
{
result = new DbClass().delMsg(id);
}
if(result)
out.println("&#x5220;&#x9664;&#x6210;&#x529F;!<br/><br/>");


for(int i =0 ;i<list.size();i++)
{

if ( (i >= (cpage - 1) * perPage) && (i < cpage * perPage) )
{

hm = (HashMap) list.get(i);
User user = factory.getUserManager().getUser( Integer.parseInt(hm.get("FID") +""));
out.println( (i+1) +".&#x6765;&#x81EA;: "+user.getUsernick()+" <a href='rep_msg.jsp?fid="+hm.get("FID")+"'>&#x56DE;&#x590D;</a> <a href='msg.jsp?op=x5220&id="+hm.get("ID")+"'>&#x5220;</a> <br/>&#x5185;&#x5BB9;:"+hm.get("CONTENT")+"<br/>&#x53D1;&#x9001;&#x65F6;&#x95F4;:"+ ((hm.get("TIME")+"").split("\\.")) [0] +"<br/>");
}

}
%>
<br/>
<%

if( ! (cpage == 1 ))
{
%>
<a href="msg.jsp?page=<%=cpage-1%>">&#x4E0A;&#x9875;</a> <br/>
<% }
if(total > 5 && cpage < tPage )
{
%>
<a href="msg.jsp?page=<%=cpage+1%>">&#x4E0B;&#x9875;</a><br/>
<%
}

%>

你可能感兴趣的:(java,jsp,WAP)