http://www.infoxa.com/asp/book_file/xxnr_book_2458.htm
解决方案 »
- weblogic加载spring失败
- 异常org.apache.tomcat.dbcp.dbcp.SQLNestedException
- 一到笔试题,请大牛给解决一下
- java.lang.OutOfMemoryError 问题
- applet嵌入html问题!急!!谢谢
- 向Mysql数据库插入数据.
- 关于js的跳转问题
- stuts源代码中比较难懂的问题,高手请进。涉及RequestUtils和FormBeanConfig的源代码
- iText的中文字体的选择?(急)
- 求助!有关Gel的调试问题
- 求一个osworkflow得流程
- DispatchAction与ActiionForm中validate验证冲突的问题
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><jsp:useBean id="db" scope="page" class="db.conn"/><%
int PageSize = 10; //设置每张网页显示十条记录
int ShowPage = 1; //设置欲显示的页数
int RowCount = 0; //ResultSet的记录总数
int PageCount = 0; //ResultSet分页后的总页数 //查询
String sql="select * from t1";
ResultSet rs = db.executeQuery(sql);
rs.last(); //将指标移至最后一条记录
RowCount = rs.getRow();
PageCount = ((RowCount%PageSize)==0?(RowCount/PageSize):(RowCount/PageSize)+1);
%>
<html>
<head>
<script>
function checkform()
{var doc = document.del
var che = "no";
if(doc.box.checked)
{che="ok";}
for(i = 0;i<doc.box.length;i++)
{
if(doc.box[i].checked)
{che = "ok";
}
}
if(che=="no")
{alert("请选择!");
return false;
}
return true;
}
</script><script language="JavaScript">
function checkAll(str)
{
var a = document.getElementsByName(str);
var n = a.length;
for (var i=0; i<n; i++)
a[i].checked = window.event.srcElement.checked;
}
function checkItem(str)
{
var e = window.event.srcElement;
var all = eval("document.hrong."+ str);
if (e.checked)
{
var a = document.getElementsByName(e.name);
all.checked = true;
for (var i=0; i<a.length; i++)
{
if (!a[i].checked){ all.checked = false; break;}
}
}
else all.checked = false;
}
</script><meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>最新提交申请表,等待初审</title>
</head>
<form name="del" method="post" action="del.jsp" target=_self onsubmit="return checkform();">
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#FFFF00">
<td height="32">ID</td>
<td>NAME</td>
<td>SEX</td>
<td>AGE</td>
<td>chose</td>
</tr>
<td height='16' colspan='5'><hr></td>
<%
String ToPage = request.getParameter("ToPage");
if(ToPage!=null) //判断是否正确取得ToPage参数
{
ShowPage = Integer.parseInt(ToPage); //取得指定显示的分页页数
if(ShowPage>PageCount) //下面的if语句将判断用户输入的页数是否正确
{
ShowPage = PageCount; //判断指定页数是否大于总页数,是则设置显示最后一页
}
else if(ShowPage<=0)
{
ShowPage=1; //若指定页数小于0,则设置显示第一页的记录
}
}
rs.absolute((ShowPage - 1)*PageSize + 1); //计算欲显示页的第一条记录的位置
%> <%
if(RowCount!=0){
for(int i=1;i<=PageSize;i++)
{
int id=rs.getInt("id");
out.print("<tr><td>");
out.print(id);
out.print("</td><td>");
out.print("<a href=ren.jsp?id="+id+">"+rs.getString("name")+"</a>");
out.print("</td><td>");
out.print(rs.getString("sex"));
out.print("</td><td>");
out.print(rs.getInt("age"));
out.print("</td><td>");
out.print("<input type='checkbox' name='box' value="+id+">");
out.print("</td></tr>");
out.print("<tr><td height='16' colspan='5'><hr></td></tr>");
//下面的if判断语句用于防止输出最后一页记录时,将记录指标移至最后一条记录之后
if(!rs.next()) //判断是否到达最后一条记录
break; //跳出for循环
}}
%>
[总共<%=RowCount%>条记录][共<%=PageCount%>页,当前第<%=ShowPage%>页]
[<%if(ShowPage!=1&&PageCount!=0){%><a href="test.jsp?ToPage=<%=1%>">第一页</a>|
<a href="test.jsp?ToPage=<%=ShowPage-1%>">上一页</a>
<%}else{%>
第一页|上一页<%}%>|
<%if(ShowPage!=PageCount&&PageCount!=0){%>
<a href="test.jsp?ToPage=<%=ShowPage+1%>">下一页</a>|
<a href="test.jsp?ToPage=<%=PageCount%>">最后一页</a><%}
else{%>下一页|最后一页<%}%>]<div align="right" >
<a href="add.jsp">添加新记录</a></div><br>
</table>
</span>
<div align="right"><input type="checkbox" name="all" onClick="checkAll('box')">全选/取消全选</div>
<div align="center">
<input type="submit" name="Submit" value="删除"></form>
</div>
</body>
</html>
/*
数据分页显示1.2
最后更新于: 2005-6-12 19:15
1>修正页面计算的BUG(当记录数刚好填满页时,会多计算一页的BUG)
2>将showPagecur()中页面参数"?page="改为了"page=",以便在页面可以自己指定URL参数。
同时要求各位小心构造页面的URL,特别是“?”或“&"符号。不然就会出错。 数据分页显示1.1
最后更新于: 2005-6-2 12:52
加入自定义颜色功能
包括:标题行背景颜色,内容行背景颜色,内容切换背景颜色,标题字体颜色,内容行字体颜色
并且内置了10种颜色方案 setStyle(int) 1-10 1为default 样式 ,当然不喜欢的话也可以自己指定颜色拉。 I WISH YOU ENJOY IT!
[email protected]
*/
package CommonBean;import java.sql.*;public class CutPage { int pagecount; //总页数
int pagesize; //每页显示记录条数
int pagecusor; //目前要显示的页面
ResultSet rs; //记录集
String linkURL; //链接到的位置。
String linkTaget = "_blank";
int keyindex; //指出数据集合中关键字的列位置。用于给上面的linkURL id带具体的URL参数值
String pageURL; //此页面的位置
String TitleTXT="点击查看详细内容"; String TableLineColor = "#000000"; //表格线颜色
String TitleBColor = "#99CCFF"; //标题行背景颜色
String TitleFColor = "#000000"; //标题字体颜色
String ContentFColor = "#000000"; //内容行字体颜色
String ContentBColor = "#FFFFFF"; //内容行背景颜色
String ContentSColor = "#CCCCCC"; //内容切换背景颜色//初始化
public void initCuter(int pagesize, int pagecusor,
ResultSet rs, String linkURL, String linkTaget,
int keyindex, String pageURL) {
try {
this.setPagesize(pagesize);
this.setPagecusor(pagecusor);
this.setRs(rs);
this.setLinkURL(linkURL);
this.setLinkTaget(linkTaget);
this.setKeyindex(keyindex);
this.setPageURL(pageURL);
rs.last();
this.setPagecount( (rs.getRow() / pagesize + 1));
}
catch (SQLException ex) {
}
}//重新计算页数
public void resetCuter() {
try {
rs.last(); this.setPagecount( (rs.getRow() / pagesize + 1));
if ( (rs.getRow() % pagesize) == 0) {
this.setPagecount(this.getPagecount() - 1);
}
}
catch (SQLException ex) {
}
}//设置显示样式
public void setStyle(int StyleIndex) {
//String aa="aaa";
switch (StyleIndex) {
default:
case 1: { //默认样式
TableLineColor = "#000000"; //表格线颜色
TitleBColor = "#99CCFF"; //标题行背景颜色
ContentBColor = "#FFFFFF"; //内容行背景颜色
ContentSColor = "#CCCCCC"; //内容切换背景颜色
TitleFColor = "#000000"; //标题字体颜色
ContentFColor = "#000000"; //内容行字体颜色
break;
}
case 2: { //配色方案2(紫色):
TableLineColor = "#983498"; //表格线颜色
TitleBColor = "#d890d8"; //标题行背景颜色
ContentBColor = "#f8dcf8"; //内容行背景颜色
ContentSColor = "#fff0ff"; //内容切换背景颜色
TitleFColor = "#602060"; //标题字体颜色
ContentFColor = "#602060"; //内容行字体颜色
break;
}
case 3: { //配色方案3(粉色):
TableLineColor = "#f00078"; //表格线颜色
TitleBColor = "#ff98do"; //标题行背景颜色
ContentBColor = "#ffe8f0"; //内容行背景颜色
ContentSColor = "#fff6fc"; //内容切换背景颜色
TitleFColor = "#602060"; //标题字体颜色
ContentFColor = "#602060"; //内容行字体颜色
break;
}
case 4: { //配色方案4(果绿色)::
TableLineColor = "#507010"; //表格线颜色
TitleBColor = "#a0dc40"; //标题行背景颜色
ContentBColor = "#e8f8d0"; //内容行背景颜色
ContentSColor = "#f8fcf0"; //内容切换背景颜色
TitleFColor = "#003300"; //标题字体颜色
ContentFColor = "#003300"; //内容行字体颜色
break;
}
case 5: { //配色方案五(金黄色):
TableLineColor = "#co7800"; //表格线颜色
TitleBColor = "#ffc562"; //标题行背景颜色
ContentBColor = "#ffeed0"; //内容行背景颜色
ContentSColor = "#Fffaf0"; //内容切换背景颜色
TitleFColor = "#754900"; //标题字体颜色
ContentFColor = "#754900"; //内容行字体颜色
break;
}
case 6: { //配色方案六(湖蓝色):
TableLineColor = "#007ca6"; //表格线颜色
TitleBColor = "#15b9ff"; //标题行背景颜色
ContentBColor = "#cef3ff"; //内容行背景颜色
ContentSColor = "#ecfbff"; //内容切换背景颜色
TitleFColor = "#00637b"; //标题字体颜色
ContentFColor = "#00637b"; //内容行字体颜色
break;
}
case 7: { //配色方案七(宝石蓝色):
TableLineColor = "#002cae"; //表格线颜色
TitleBColor = "#7d9aff"; //标题行背景颜色
ContentBColor = "#d0dcff"; //内容行背景颜色
ContentSColor = "#eef2ff"; //内容切换背景颜色
TitleFColor = "#001c7b"; //标题字体颜色
ContentFColor = "#001c7b"; //内容行字体颜色
break;
}
case 8: { //配色方案8(酱红色):
TableLineColor = "#db3700"; //表格线颜色
TitleBColor = "#ff8c6a"; //标题行背景颜色
ContentBColor = "#ffd2c4"; //内容行背景颜色
ContentSColor = "#ffede8"; //内容切换背景颜色
TitleFColor = "#8a1f00"; //标题字体颜色
ContentFColor = "#8a1f00"; //内容行字体颜色
break;
}
TableLineColor = "#cd37ff"; //表格线颜色
TitleBColor = "#ebacff"; //标题行背景颜色
ContentBColor = "#f9e6ff"; //内容行背景颜色
ContentSColor = "#Fdf4ff"; //内容切换背景颜色
TitleFColor = "#205838"; //标题字体颜色
ContentFColor = "#205838"; //内容行字体颜色
break;
}
case 10: { //配色方案10(西瓜红色):
TableLineColor = "#ff51b0"; //表格线颜色
TitleBColor = "#ff8cc6"; //标题行背景颜色
ContentBColor = "#ffe1f0"; //内容行背景颜色
ContentSColor = "#fff4fa"; //内容切换背景颜色
TitleFColor = "#bf0069"; //标题字体颜色
ContentFColor = "#bf0069"; //内容行字体颜色
break;
} } }