按键二;根据条件查询后显示结果

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'find_stu_3.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>
<head><title>由提交页面获取查询条件并实现查询的页面</title></head>
<body><center>
<% String driverName="com.mysql.jdbc.Driver";
String dbName="MyLogin";
String userName="root";
String userPwd="lovezjl";
String url1="jdbc:mysql://localhost:3306/MyLogin";
String url2="?user=root&password=lovezjl";
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(driverName);
Connection conn=DriverManager.getConnection(url);

request.setCharacterEncoding("UTF-8");
String sex1=request.getParameter("s1");
String sushe1=(request.getParameter("s2"));
String sql="select * from student_xinxi1 where sex=? and sushe=?";
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setString(1,sex1);
pstmt.setString(2,sushe1);


ResultSet rs=pstmt.executeQuery();
rs.last();%>
<font size="5" color ="red"><%=rs.getRow()%></font>条信息
<table border="2" bgcolor="cceeec" width="650">
<tr bgcolor="CCCCCC" align="center">
<td>记录条数</td><td>宿舍号</td><td>订水数量</td><td>是否接单</td><td>送单状态</td>
</tr>
<%rs.beforeFirst();
while(rs.next()){
%> <tr align="center">
<td><%=rs.getRow() %></td>
<td><%=rs.getString("sushe") %></td>
<td><%=rs.getString("shuliang") %></td>
<td><%=rs.getString("jiedan") %></td>
<td><%=rs.getString("song") %></td>
</tr>
<%} %>
</table>
</center>
<%if(rs!=null){rs.close();}
if(pstmt!=null){pstmt.close();}
if(conn!=null){conn.close();} %>

<style type="text/css">
body{
background:url("image/444.jpg");
background-size:100%;
}

</center> </body>
</html>

posted @ 2017-12-10 22:54  can丶  阅读(269)  评论(0编辑  收藏  举报