?? list.jsp
字號:
<%@ page language="java" contentType="text/html; charset=GB2312" pageEncoding="GB2312"%>
<%@page import="com.ideas.util.*,java.util.*"%>
<%
//超時提示
if((String)session.getAttribute("login")==null) {
response.sendRedirect("../session.htm");
}
%>
<jsp:useBean id="myBean" scope="page" class="com.ideas.bean.menu2Bean"/>
<%
int intPageSize; //一頁顯示的記錄數
int intRowCount; //記錄總數
int intPageCount; //總頁數
int intPage; //待顯示頁碼
String strPage;
//設置一頁顯示的記錄數
intPageSize = Configuration.Number_shown;
//取得待顯示頁碼
strPage = request.getParameter("page");
if(strPage==null){//表明在QueryString中沒有page這一個參數,此時顯示第一頁數據
intPage = 1;
}
else{//將字符串轉換成整型
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
int recno=(intPage-1)*intPageSize+1;
//DBConnectionManager connMgr=DBConnectionManager.getInstance();
//Connection con = connMgr.getConnection(Configuration.ConnectionPoolName);
//創建數據庫連接
if (!myBean.getMyConnPool()) {
out.println("不能獲取數據庫連接.");
return;
}
//edit
String id1 = (String)request.getParameter("id");
String type1 = (String)request.getParameter("type");
String name1 = (String)request.getParameter("name");
String id1_1 = (String)request.getParameter("id1");
String href1 = (String)request.getParameter("href");
String isuse1 = (String)request.getParameter("isuse");
if(name1==null)name1 = "";
name1 = new String(name1.getBytes("ISO-8859-1"),"GBK");
if(type1==null)type1 = "";
int error = 0;
if(type1.equals("1"))
{
Hashtable hash= new Hashtable();
hash.put("name", name1);
hash.put("id1", id1_1);
hash.put("href", href1);
hash.put("isuse", isuse1);
error = myBean.add(hash);
}
else if(type1.equals("2"))
{
myBean.setID(id1);
Hashtable hash= new Hashtable();
hash.put("name", name1);
hash.put("id1", id1_1);
hash.put("href", href1);
hash.put("isuse", isuse1);
error = myBean.mod(hash);
}
else if(type1.equals("3"))
{
myBean.setID(id1);
myBean.del();
}
//取得當前頁的數據
Vector vect = myBean.getCurPage(intPage,intPageSize);
//獲取記錄總數
intRowCount = Integer.parseInt((String)vect.get(0));
//記算總頁數
intPageCount = Integer.parseInt((String)vect.get(1));
//調整待顯示的頁碼
if(intPage>intPageCount) intPage = intPageCount;
%>
<html>
<head>
<title>二級菜單維護</title>
<link rel="STYLESHEET" type="text/css" href="../css/yj.css">
</head>
<body>
<center><H1>二級菜單維護</H1></center>
<h2> 第<%=intPage%>頁 共<%=intPageCount%>頁(<%=intRowCount%>條) <a href="list.jsp?">首頁</a> <%if(intPage>1){%><a href="list.jsp?&page=<%=intPage-1%>">上一頁</a><%}%> <%if(intPage<intPageCount){%><a href="list.jsp?&page=<%=intPage+1%>">下一頁</a><%}%> <a href="list.jsp?&page=<%=intPageCount%>">尾頁</a> <a onclick="javascript:window.location.reload();" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';" style="cursor:hand;" ><font color="blue">刷新數據</font></a></h2>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="8%" align="center" >序號</th>
<th width="20%" align="center" >二級菜單名稱</th>
<th width="20%" align="center" >所在一級菜單</th>
<th width="20%" align="center" >子頁標頭圖片</th>
<th width="*" align="center" >審核</th>
<th width="19%" align="center"><A onclick="add('');" style="cursor:hand;" class="hold1">〖新增〗</A></th>
<tr>
<%
if(intPageCount>0){
for (int line=2;line<vect.size();line++) {
Hashtable hash = (Hashtable)vect.get(line);
String mode=null;
if (line%2==1)
mode="row3";
else
mode="row1";
String id = (String)hash.get("id");
String isuse = (String)hash.get("isuse");
String t = "通過";
if(isuse.equals("0"))t = "掛起";
%>
<tr>
<td height=21 align="center" class="<%=mode%>" ><%=recno++%></td>
<td align="center" class="<%=mode%>" ><%=hash.get("name")%></td>
<td align="center" class="<%=mode%>" ><%=hash.get("menu1name")%></td>
<td align="left" class="<%=mode%>" ><%=hash.get("href")%></td>
<td align="center" class="<%=mode%>" ><%=t%></td>
<td align="center" class="<%=mode%>">
<A onclick="edit('<%=id%>');"style="cursor:hand;" class="hold">『修改』</A>
<A onclick="del('<%=id%>');" style="cursor:hand;" class="hold">『刪除』</A>
</td>
</tr>
<%
}
}//end for%>
</table>
<form name=form1 action="" method=post>
</form>
<%
//connMgr.freeConnection(Configuration.ConnectionPoolName, con);
myBean.releaseMyConnPool();
%>
<script>
function add()
{
document.all.form1.action = "edit.jsp?type=1&page=<%=intPageCount%>";
document.all.form1.submit();
}
function edit(id)
{
document.all.form1.action = "edit.jsp?type=2&id="+id+"&page=<%=intPageCount%>";
document.all.form1.submit();
}
function del(id)
{
if(!confirm("是否真的要刪除?"))
{
}
else
{
document.all.form1.action = "list.jsp?type=3&id="+id+"&page=<%=intPageCount%>";
document.all.form1.submit();
}
}
</script>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -