4
回答



我是这样写的:
jsp页面:${toolBar }
action: // 保存工具条
request.setAttribute("toolBar", toolBar);
request.setAttribute("toolBar", toolBar);
page类:
/**
* 客户端显示的工具条
*/
public String getToolBar(String url) {
String str, temp;
//用于判断url中是否存在?
if(url.indexOf("?") == -1) {
temp = "?";
} else {
temp = "&";
}
str = "<form method='post' name='frmPage' action='" + url + "'> ";
str += "";
str += "<span style='font-size: 12px; font-weight: bold;'>";
//判断是否是首页
if(isFirst()) {
str += "首页 上一页 ";
} else {
str += "<a href='" + url + temp + this.getFirst() + "'>首页</a> ";
str += "<a href='" + url + temp + "cur_page=" + this.previous() + "'>上一页</a> ";
}
//判断是否是最后一页
if(isLast()) {
str += "下一页 尾页 ";
} else {
str += "<a href='" + url + temp + "cur_page=" + this.next() + "'>下一页</a> ";
str += "<a href='" + url + temp + "cur_page=" + this.getLast() + "'>尾页</a> ";
}
str += " 共<b>" + this.rowCount + "</b>条记录 ";
str += " 转到<select name='page' onChange=\"location='" + url + temp + "cur_page='+this.options[this.selectedIndex].value\">";
for(int i = 1; i <= this.pageCount; i++) {
//判断是否是当前页,若是,则默认为选中当前页
if(i == curPage)
str += "<option value='" + i + "' selected>第" + i + "页</option>";
else
str += "<option value='" + i + "'>第" + i + "页</option>";
}
str += "<select></span></form>";
return str;
}
谁会?先谢谢啦!
/**
* 客户端显示的工具条
*/
public String getToolBar(String url) {
String str, temp;
//用于判断url中是否存在?
if(url.indexOf("?") == -1) {
temp = "?";
} else {
temp = "&";
}
str = "<form method='post' name='frmPage' action='" + url + "'> ";
str += "";
str += "<span style='font-size: 12px; font-weight: bold;'>";
//判断是否是首页
if(isFirst()) {
str += "首页 上一页 ";
} else {
str += "<a href='" + url + temp + this.getFirst() + "'>首页</a> ";
str += "<a href='" + url + temp + "cur_page=" + this.previous() + "'>上一页</a> ";
}
//判断是否是最后一页
if(isLast()) {
str += "下一页 尾页 ";
} else {
str += "<a href='" + url + temp + "cur_page=" + this.next() + "'>下一页</a> ";
str += "<a href='" + url + temp + "cur_page=" + this.getLast() + "'>尾页</a> ";
}
str += " 共<b>" + this.rowCount + "</b>条记录 ";
str += " 转到<select name='page' onChange=\"location='" + url + temp + "cur_page='+this.options[this.selectedIndex].value\">";
for(int i = 1; i <= this.pageCount; i++) {
//判断是否是当前页,若是,则默认为选中当前页
if(i == curPage)
str += "<option value='" + i + "' selected>第" + i + "页</option>";
else
str += "<option value='" + i + "'>第" + i + "页</option>";
}
str += "<select></span></form>";
return str;
}