继续在ssh中实现分页排序
Posted 普通网友
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了继续在ssh中实现分页排序相关的知识,希望对你有一定的参考价值。
https://blog.csdn.net/zhupengqq/article/details/90691291
忘了说了,最重要的是在这个jsp页面上
CommonDAO dao = (CommonDAO)Info.getDao(request,"CommonDAO");
String hql = "from TStu where 1=1 "; //week(savetime) = week(now())
String url = "stuMana.action?1=1";
System.out.println(hql);
PageManager pageManager = PageManager.getPage(url,3, request);
pageManager.doList(hql);
PageManager bean= (PageManager)request.getAttribute("page");
ArrayList<TStu> startlist=( ArrayList<TStu>)bean.getCollection();
ArrayList<TStu> tzlist = new ArrayList<TStu>();
for(TStu startTzinfo:startlist)
ArrayList htlist = (ArrayList)dao.findByHql("from TStu where stuId="+startTzinfo.getStuId());
//startTzinfo.setHtnum(String.valueOf(htlist.size()));
tzlist.add(startTzinfo);
System.out.println("排序前:" +startlist);
System.out.println("tzlist=="+tzlist.size());
ListSortUtil<TStu> sortList = new ListSortUtil<TStu>();
//排序字段 userId
sortList.sort(tzlist, "stuRealname", "desc"); //排序规则进行升序
System.out.println("排序后:" +tzlist);
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.dao.CommonDAO"%>
<%@page import="com.util.Info"%>
<%@page import="com.util.PageManager"%>
<%@page import="com.dao.CommonDAO"%>
<%@page import="com.util.Info"%>
<%@page import="com.model.TStu"%>
<%@page import="com.util.*"%>
<%@page import="com.util.PageManager"%>
<%
String path = request.getContextPath();
%>
<!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="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />
<link rel="stylesheet" type="text/css" href="<%=path %>/css/base.css" />
<script language="javascript">
function stuDel(stuId)
if(confirm('您确定删除吗?'))
window.location.href="<%=path %>/stuDel.action?stuId="+stuId;
function stuEditPre(stuId)
window.location.href="<%=path %>/stuEditPre.action?stuId="+stuId;
function stuAdd()
var url="<%=path %>/admin/stu/stuAdd.jsp";
//var n="";
//var w="480px";
//var h="500px";
//var s="resizable:no;help:no;status:no;scroll:yes";
//openWin(url,n,w,h,s);
window.location.href=url;
function daochu()
var url="<%=path %>/stuDaochu.action";
window.open(url,"_self");
function daoru()
document.getElementById("liu").style.display="block";
</script>
</head>
<body leftmargin="2" topmargin="2" background='<%=path %>/images/allbg.gif'>
<script type="text/javascript">
function exportExcel()
window.open('stuMana.action?exportToExcel=YES');
</script>
<!-- 显示网格线 -->
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>工作表标题</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo />
</x:Print>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
<!-- 显示网格线 -->
<script type="text/javascript" src="../js/js.js"></script>
</HEAD>
<%
String exportToExcel = request.getParameter("exportToExcel");
if (exportToExcel != null
&& exportToExcel.toString().equalsIgnoreCase("YES"))
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename="
+ "student.xls");
%>
<br/><br/>
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px">
<tr bgcolor="#E7E7E7">
<td height="14" colspan="10" background="<%=path %>/images/tbg.gif"> 学生管理 </td>
</tr>
<tr align="center" bgcolor="#FAFAF1" height="22">
<td width="10%">学号</td>
<td width="10%">姓名</td>
<td width="10%">性别</td>
<td width="10%">学院</td>
<td width="10%">班级</td>
<td width="10%">楼号</td>
<td width="10%">宿舍号</td>
<td width="10%">登陆账号</td>
<td width="10%">登录密码</td>
<td width="10%">操作</td>
</tr>
<%
CommonDAO dao = (CommonDAO)Info.getDao(request,"CommonDAO");
String hql = "from TStu where 1=1 "; //week(savetime) = week(now())
String url = "stuMana.action?1=1";
System.out.println(hql);
PageManager pageManager = PageManager.getPage(url,3, request);
pageManager.doList(hql);
PageManager bean= (PageManager)request.getAttribute("page");
ArrayList<TStu> startlist=( ArrayList<TStu>)bean.getCollection();
ArrayList<TStu> tzlist = new ArrayList<TStu>();
for(TStu startTzinfo:startlist)
ArrayList htlist = (ArrayList)dao.findByHql("from TStu where stuId="+startTzinfo.getStuId());
//startTzinfo.setHtnum(String.valueOf(htlist.size()));
tzlist.add(startTzinfo);
System.out.println("排序前:" +startlist);
System.out.println("tzlist=="+tzlist.size());
ListSortUtil<TStu> sortList = new ListSortUtil<TStu>();
//排序字段 userId
sortList.sort(tzlist, "stuRealname", "desc"); //排序规则进行升序
System.out.println("排序后:" +tzlist);
for(TStu tz:startlist)
%>
<s:iterator value="#request.stuList" id="stu">
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='red';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22">
<td bgcolor="#FFFFFF" align="center">
<%=tz.getStuXuehao()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getStuRealname()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getStuSex()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getStuZhengzhimianmao()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getStuCard()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getLouhao()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getSushehao()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getLoginName()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<%=tz.getLoginPw()%>
</td>
<td bgcolor="#FFFFFF" align="center">
<a href="#" onclick="stuEditPre( <%=tz.getStuId()%>)" class="pn-loperator">修改</a>
<a href="#" onclick="stuDel(<%=tz.getStuId()%>)" class="pn-loperator">删除</a>
</td>
</tr>
</s:iterator>
<% %>
</table>
<div style="text-align: center">
<div >
<div id="LAY_page">$page.info </div>
</div>
</div>
<table width='98%' border='0'style="margin-top:8px;margin-left: 5px;">
<tr>
<td>
<input type="button" value="添加" style="width: 80px;" onclick="stuAdd()" />
</td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td>
<a href="javascript:exportExcel();" style="width: 80px;"><h3> <font style="color: red">EXCEL批量导出</font></h3></a>
</td>
</tr>
</table>
</body>
</html>
以上是关于继续在ssh中实现分页排序的主要内容,如果未能解决你的问题,请参考以下文章