⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thingtome1.jsp

📁 此资源是jsp应用开发 邓子云等编写的一书里的源代码
💻 JSP
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*,javax.naming.*,javax.sql.DataSource" %>
<html>
  <body bgcolor="#DCDADA">
  当前位置:行政审批-->安排审批事务<br>
 <%//------会话检查------
 	if(session.getAttribute("oaUserId")==null)
 		response.sendRedirect("../user/login.jsp");
 %> 
 <%int pageSize=10;//每页显示的记录条数
  	int allRecordCount=0;//记录总条数
  	int pageRecordCount=0;//当前页记录条数
  	int pageCount=0;//总页数
  	int diPage=1;//当前页码
  	//------接收请求参数------  	
  	try{
  		diPage=Integer.parseInt(request.getParameter("diPage"));
  	}catch(Exception e){
  		diPage=1;
  	}
  %>
  <%//------构造查询的SQL语句------
  	//sqlStr1为查询到当前页数据的SQL语句
  	//sqlStr2为查询到总记录条数的SQL语句
  	String sqlStr1="select top "+diPage*pageSize+" * from thingArra where "+
  		"thingId not in (select top "+(diPage-1)*pageSize+" thingId from"+
  		" thingArra where oaUserId="+session.getAttribute("oaUserId")+
  		" order by thingId desc) and oaUserId="+session.getAttribute("oaUserId")+
  		" order by thingId desc"; 		
  	String sqlStr2="select count(*) as allCount from thingArra where oaUserId="+
  		session.getAttribute("oaUserId");
  %>
  <%//------得到数据库连接------
  	Context initCtx = new InitialContext(); 
	Context ctx = (Context) initCtx.lookup("java:comp/env");
	Object obj = (Object) ctx.lookup("jdbc/sqlserver");
	DataSource ds = (javax.sql.DataSource)obj;
	Connection conn = ds.getConnection();
  %>
  <%//------得到总页数、总记录条数与当前页记录条数------
  	java.sql.Statement sql1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
  	java.sql.ResultSet rs1=null;
  	rs1=sql1.executeQuery(sqlStr2);
  	if(rs1!=null){
  		//---得到总页数、总记录条数与当前页记录条数---
  		rs1.next();
  		allRecordCount=rs1.getInt("allCount");
  		if(allRecordCount%pageSize==0)
  			pageCount=allRecordCount/pageSize;
  		else
  			pageCount=(int)(allRecordCount/pageSize)+1;
  		if(diPage==pageCount||pageCount==0)//最后一页或没有数据
  			pageRecordCount=allRecordCount-(diPage-1)*pageSize;
  		else
  			pageRecordCount=pageSize;
  	}
  %>
  <table border="1" CELLSPACING=0 CELLPADDING=0>
  	<tr><td colspan="3" align="center">
  		查看我的审批记录(共<%=allRecordCount%>条,当前页<%=pageRecordCount%>条)
  		&nbsp;&nbsp;&nbsp;&nbsp;
  		<%if(diPage!=1){//不是第一页
  			out.print("<a href='viewInfo1.jsp?diPage=1'>首页</a>&nbsp;");
  			out.print("<a href='viewInfo1.jsp?diPage="+(diPage-1)+"'>上一页</a>&nbsp;");
  		  }
  		  if(diPage!=pageCount&&pageCount!=0){//不是最后一页
  			out.print("<a href='viewInfo1.jsp?diPage="+(diPage+1)+"'>下一页</a>&nbsp;");
  			out.print("<a href='viewInfo1.jsp?diPage="+pageCount+"'>尾页</a>&nbsp;");
  		  }
  		%>
  	</td>
  	</tr>
  	<tr><td>审批事务标题</td>
  	    <td>查看详细说明与审批记录?</td>
  		<td>审批?</td>
  	</tr>
  	<%//------得到当前面数据并显示------
  	java.sql.ResultSet rs2=null;
  	java.sql.Statement sql2=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
  	rs2=sql2.executeQuery(sqlStr1);
  	if(rs2!=null){
  		while(rs2.next()){
  			String sqlStr3="select * from thing where thingId="+rs2.getLong("thingId");
  			java.sql.Statement sql3=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
  			java.sql.ResultSet rs3=null;
  			rs3=sql3.executeQuery(sqlStr3);
  			if(rs3.next()){
  	%>
  	<tr><td>[<%=rs3.getString("thingAddTime").substring(0,10)%>]<%=rs3.getString("thingTitle")%></td>
  		<td><a href="#" onclick="window.open('manRecord.jsp?thingId=<%=rs2.getLong("thingId")%>')">查看</a></td>
  		<td><a href="thingToMe2.jsp?thingId=<%=rs2.getLong("thingId")%>&thingArraId=<%=rs2.getLong("thingArraId")%>" target="_blank">审批</a></td>
  	</tr>	
  	<%		}
  		}
  	 }%>
  	<%
  	  if(conn!=null)
  		conn.close();
  	%>
  </table>
  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -