Oracle & JSP 开发的小型信息管理系统 (二) 源代码1

<< 建立连接 | [Eclipse笔记]在SWT中有效的管理图形系统资源 >>
  发布日期:13/12/2007 02:43:18 发布者:[快乐开发网]  来源:[本站]  浏览:[]  评论:[]
字体:    

信 息 列 表





<%int intPageSize;int intRowCount;//記錄總數int intPageCount;//總頁數int intPage;//頁面參數String strPage;//定義變數用來傳遞pageint i,j;intPageSize=5;//定義每頁顯示5條記錄strPage=request.getParameter("page");//取得當前的頁碼if(strPage==null){//判斷初始頁面,如果沒有顯示記錄,就置為第一頁intPage=1;}else{intPage=Integer.parseInt(strPage);//將strPage轉化為整數if(intPage<1) intPage=1;}

String sqlname="select count(article_id) from learning ";

//sqlname="select count(article_id) from learning where title like '%"+keyword+"%' and types like '%"+typename+"%' order by article_id desc";

PreparedStatement ps=conn.prepareStatement(sqlname);ResultSet rs1=ps.executeQuery();rs1.next();intRowCount=rs1.getInt(1);//取得整數保存與intRowCount變數中intPageCount=(intRowCount+intPageSize-1)/intPageSize;//計算出總頁數(記錄總數+每頁顯示的記錄-1)/每頁顯示的記錄)if(intPage>intPageCount)intPage=intPageCount;

String query=" select * from learning order by article_id ";

ResultSet rs=ps.executeQuery(query);//執行sql,按照時間先後排序顯示i=(intPage-1)*intPageSize;for(j=0;j<%-- 設置intPage參數 --%>

第<%=intPage%>頁 &nbsp;&nbsp;&nbsp;共<%=intPageCount%>頁&nbsp;&nbsp;&nbsp; <%if(intPage 下一頁&nbsp;&nbsp;&nbsp; <%}%> <%if(intPage>1){%> 上一頁&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%}%>

<%if(intRowCount==0){%> 對不起,還沒有資料! <%}else{%> <%-- 顯示每頁的資料 (根據i的值判斷每頁的5條記錄) --%> <% i=0; while(i <% i++;//通過I迴圈設置每頁的頁數 } %> <%}%>
ID 號 信 息 名 稱 上 載 時 間 點 擊

<%=rs.getString("article_id")%>

)" title="<%=rs.getString("title")%>"><%=rs.getString("title")%>
<%=rs.getString("date_and_time")%>

<%=rs.getString("hits")%>

第<%=intPage%>頁 &nbsp;&nbsp;&nbsp;共<%=intPageCount%>頁&nbsp;&nbsp;&nbsp; <%if(intPage 下一頁&nbsp;&nbsp;&nbsp; <%}%> <%if(intPage>1){%> 上一頁&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%}%>
到第 <% String userName=(String)session.getAttribute("admin"); if(userName==null){userName="";} if(userName.equals("admin")){ %> &nbsp; &nbsp;系統管理<%} else{%> &nbsp; &nbsp;登錄系統管理<%}%>

<%rs.close();

conn.close(); %>

Copyright &copy;moonsoft 2004





****************************************//login.jsp 登录页面

<%@ page contentType="text/html;charset=big5"%> 信息查詢系統

管理系統

用戶名稱

管理密碼

&nbsp; &nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;





************************//chklogin验证登录页面,如果正确,sendRedirect 到manage.jsp

<%@ page contentType="text/html;charset=gb2312"%><%@ page import="java.sql.*"%> chklogin <%!String userName, password, adminvalue;%> <% adminvalue="admin"; request.setCharacterEncoding("big5"); userName=request.getParameter("username").trim(); password=request.getParameter("password").trim(); if(userName==null) {response.sendRedirect("index.jsp");} if(password==null) {response.sendRedirect("index.jsp");} if(userName.equals(adminvalue)&&password.equals(adminvalue)) { /*Cookie theadminok=new Cookie("adminok", "true"); response.addCookie(theadminok); response.sendRedirect("manage.jsp");*/ HttpSession se=request.getSession(); se.setAttribute("admin",userName); response.sendRedirect("manage.jsp"); } else{response.sendRedirect("index.jsp");} %>

打印 】【 收藏 】【 推荐 】 
相关文章
·暂无
推荐文章
 ·暂无
热门文章
评一评
正在读取…

  笔名:

  评论:

   

【注】 发表评论必需遵守以下条例: