求页面分页代码(hibernate-3.1.3)

ScholarJia 2006-03-29 02:54:47
<%@page contentType="text/html;charset=gb2312"%>
<%@include file="public.jsp"%>


<%
//参数说明
//数据查询条件,值域:timeout/allorder
String condition=getString(request,"condition","allorder");
%>
<%
ObjectSession objectSession=null;
List list_data=null;
new ObjectSessionFactory().close();

try{
objectSession = new ObjectSessionFactory().open();
list_data=objectSession.find("from User");
}catch(Exception e){
System.out.println(e);
}

%>

<style type="text/css">
<!--
.style5 {font-size: 13px; }
-->
</style>

<table width="97%" height="22%" border="0" >
<tr height="8%" >
<th width="10%"scope="col"><div align="left"><a href="./user_list.jsp">人员信息</a></div></th>
<th width="10%"scope="col"><div align="left"><a href="#" onclick="parent.detailFrame.location.replace('./user_new.jsp')">新增人员</a></div></th>
<th width="11%"scope="col"><a href="./group_list.jsp">群组信息</a></th>
<th width="11%"scope="col"><a href="#" onclick="parent.detailFrame.location.replace('./group_new.jsp')">新增群组</a></th>
<th width="12%"scope="col"> </th>
<th width="9%"scope="col"> </th>
<th width="9%"scope="col"> </th>
<th width="9%"scope="col"> </th>
<th width="9%"scope="col"> </th>
</tr>
<tr>
<th height="88" colspan="10" scope="row"><table width="100%" border="0" cellspacing="1" bgcolor="#666666">
<tr bgcolor="#CCCCCC">
<th width="122" height="16" scope="col"> <div align="left" class="style5">
<div align="center">姓名</div>
</div></th>
<th width="131" scope="col"><div align="left" class="style5">
<div align="center">用户</div>
</div></th>
<th width="105" scope="col"><div align="left" class="style5">
<div align="center">群组</div>
</div></th>
<th width="149" scope="col"><div align="left" class="style5">
<div align="center">手机号码</div>
</div></th>
<th width="115" scope="col"><div align="left" class="style5">邮件地址</div></th>
<th width="177" scope="col">
<div align="center" class="style5">
操作
</div></th>
</tr>
<%
for(int i=0;list_data!=null&&i<list_data.size();i++){
User user=(User)list_data.get(i);
Iterator it=null;
try{
Set groupSet=user.getGroups();
it=groupSet.iterator();
}catch(Exception e){
it=null;
}
String groupInfo="";
for(int k=0;it!=null&&it.hasNext();){
groupInfo+=" "+((Group)it.next()).getName();
}


%>
<tr bgcolor="#FFFFFF">
<th scope="row"><div align="left"><%=getISO8859(user.getName())%></div></th>
<td><div align="left"><%=getISO8859(user.getUsername())%></div></td>
<td><%=getISO8859(groupInfo)%></td>
<td><%=getISO8859(user.getMobileTel())%></td>
<td><%=getISO8859(user.getEmail())%></td>
<td class="style5"><a href="#" onclick="parent.detailFrame.location.replace(this.url)" url="detailForm.jsp?id=<%=user.getForm().getId()%>">查看明细</a></td>
</tr>
<%}%>
</table></th>
</tr>
</table>
...全文
152 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ScholarJia 2006-03-29
  • 打赏
  • 举报
回复
谢谢了,不过数据库部分要用hibernate-3.1.3解决?
eidolon_warrior 2006-03-29
  • 打赏
  • 举报
回复

//分页显示结果用参数
int EveryPage=10;//每页显示的记录数;
int OnPage=1; //当前显示的页数;
int Total=0;//记录的总数;
int TotalPage=0;//记录的总页数;
java.util.Vector result = (java.util.Vector)v.get(1);
System.out.println("v.get(1)"+result.toString()+"\n");
Total = result.size();
if(Total%EveryPage==0)
TotalPage=Total/EveryPage;
else
TotalPage=Total/EveryPage+1;
//取得文本框输入的值;
String Pages=request.getParameter("Pages");

if(Pages!=null)
{
OnPage=Integer.parseInt(Pages);//把Pages转换为整型;
//根据输入的值,判断应显示的页;
if(OnPage>TotalPage)
{
OnPage=TotalPage;
}
else if(OnPage<=0)
{
OnPage=1;
}
}
System.out.println("nnd is over!");

%>
<link href="/style.css" rel="stylesheet" type="text/css">

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td height="13" colspan="3"><div align="center"></div></td>
</tr>

<tr>


<td width="82%" align="center" valign="top"><div align="center">
<!--
<form action="" method="post" name="register" target="_self" id="register">
-->
<table width="100%" border="0" cellpadding="3" cellspacing="1">
<tr bgcolor="#6595D6">
<th height="20" colspan="5" scope="col"><span class="style3">标准浏览</span></th>
</tr>
<tr bgcolor="#ACC7EA">
<td width="35%" height="20" bgcolor="#ACC7EA"><div align="center" class="style12">标准编号</div></td>
<td width="35%" bgcolor="#ACC7EA"><div align="center" class="style12">标准名称</div></td>
<td width="10%"><div align="center"></div></td>
<td width="10%"> </td>
<td width="10%"> </td>
</tr>
<%
for(int i=1;i<=EveryPage;i++)
{
int j = (OnPage-1)*EveryPage+(i-1);
SchemaInfoBean mybean = new SchemaInfoBean();
if(j < Total)
{
mybean = (SchemaInfoBean)result.get(j);
}
else
{
break;
}

%>

<tr bgcolor="#EEEEEE">
<td height="19" bgcolor="#EEEEEE"><%=mybean.getSchemaID()%></td>
<td bgcolor="#EEEEEE"><%=mybean.getSchemaName()%></td>
<td><div align="center" class="style2"><a href=ViewSchema.jsp?SchemaID=<%=mybean.getSchemaID()%>>查看</a></div></td>
<td><div align="center" class="style2"><a href=EditSchInfo.jsp?SchemaID=<%=mybean.getSchemaID()%>>修改</a></div></td>
<td><div align="center" class="style2"><a href=DelSch.jsp?SchemaID=<%=mybean.getSchemaID()%> onclick='javascript:if (confirm("您确定要删除此记录吗?")) {""} else {return false}'>删除</a></div></td>
</tr>
<% }

%>
<tr>
<form action="BrowseSchema.jsp" method="POST">
<th colspan="3"><div align="left">标准查询
<input name="PM" type="text"size="18" height="20">
<input type="submit" name="query" value="查询" size="20" ></div></th>
</form>

<th colspan="2">
<%
for(int i=1;i<=TotalPage;i++)
{
String p = String.valueOf(i);
%>
<a href=BrowseSchema.jsp?PM=<%=pm%>&Pages=<%=p%>><%= p %></a>
<%
}%>
</th>


</tr>


</table>
<!--
</form>
-->
<p> </p>
</div></td>
</tr>
<tr>
<td colspan="3" valign="top"> </td>
</tr>
</table>

62,629

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧