结对作业(地铁项目)09
stationsearchjudge.jsp
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询</title>
</head>
<body style="text-align:center">
查询结果
<style>
body {
margin:0px;
background: url(images/2.png) no-repeat;
background-size:100% 100%;
background-attachment:fixed;
}
input {
width: 250px;
height: 44px;
border: none;
/* 元素周围的轮廓无效 */
outline: none;
/* 为元素指定的任何内边距和边框都将在已设定的宽度和高度内进行绘制 */
box-sizing: border-box;
display: block;
padding: 0 16px;
}
.input-text {
margin: 5px auto;
border-radius: 16px;
}
.input-text:hover {
border: 0.5px solid rgb(76, 76, 233);
transition: 0.5s;
border-radius: 4px;
}
</style>
<p>
<jsp:useBean id="util" class="User.subway" scope="page" />
<%
String station=(String)request.getParameter("station_name");
if(station==""){
out.print("<script language='javaScript'> alert('输入为空'); window.history.back(-1); </script>");
}
else
{
%>
<table border="1"style="text-align:center;">
<tr>
<td align="center" width=6%>线路</td>
<td align="center" width=3%>站点</td>
</tr>
<%
int i=0;
Connection connection = util.getConnection();
PreparedStatement preparedStatement=null;
ResultSet rs=null;
try {
String sql= " select * from bj_subway ";
preparedStatement=connection.prepareStatement(sql);
rs=preparedStatement.executeQuery();
while(rs.next())
{
i++;
if (station.equals(rs.getObject(3))){
%>
<tr>
<td align="center"><%=rs.getObject(2) %></td>
<td align="center"><%=rs.getObject(3) %></td>
</tr>
<%
}
}
if(i==0)
{
out.print("<script language='javaScript'> alert('没有查询到有关信息'); window.history.back(-1); </script>");
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
util.close(rs);
util.close(preparedStatement);
util.close(connection);
}
}
%>
</table>
<p style="text-align:center;color: black; font-family: 宋体; font-size: 20px">
<br> <input class="input-text" type="button" value="返回菜单" onclick="location.href='menu.jsp'" /> <br>
</p>
</body>
</html>