Html界面简介:
主要结构目录如下:
重要的JSP页面展示:
展示环境信息页面JSP(listXx.jsp)
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
.tb_grad{
text-align: center;
font-size: 25px;
font-family: "宋体";
}
.tb_grad caption{
font-weight: 800;
color: #FF0000;
margin-bottom: 20px;
}
.tb_grad th{
border: 2px solid #b83d00;
}
.tb_grad td{
border: 1px solid #b50000;
}
.tb_grad td span a{
text-decoration: none;
}
.pagination {
display: inline-block;
}
.pagination a {
color: black;
float: left;
padding: 8px 16px;
text-decoration: none;
}
.pagination a.active {
background-color: #4CAF50;
color: white;
}
.pagination a:hover:not(.active) {
background-color: #ddd;
}
body{
background-image: url(img/bj.jpg);
background-size: cover;
}
</style>
</head>
<body>
<h1>欢迎来到智慧家居环境监测系统数据页面</h1>
<hr>
<table class="tb_grad" border="0" cellspacing="0" cellpadding="0" width="1200px" align="center">
<caption>环境信息列表</caption><tr>
<th>温度</th>
<th>湿度</th>
<th>光照</th>
<th>时间</th>
<th>操作</th>
</tr>
<c:forEach items="${list}" var="arti">
<tr>
<td><a href="findByIdXx.do?id=${arti.id}">${arti.wd}</a></td>
<td><a href="findByIdXx.do?id=${arti.id}">${arti.sd}</a></td>
<td><a href="findByIdXx.do?id=${arti.id}">${arti.gz}</a></td>
<td><a href="findByIdXx.do?id=${arti.created}">${arti.created}</a></td>
<td>
<a href="deleteXx.do?id=${arti.id}"
onclick="return window.confirm('确定删除吗?')">删除信息</a>
</td>
</tr>
</c:forEach>
</table>
<br><hr>
<br />
<div align="center" >
<input class="blue.round:after" type ="button" value = "返回主页" color = "#666666" onclick="window.location.href='main.html'">
</div>
</body>
</html>
根据输入时间查询信息JSP介绍(MorrTime.jsp)
<%@ page language="java" import="java.util.*, java.sql.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%request.setCharacterEncoding("UTF-8");%>
<%response.setCharacterEncoding("UTF-8");%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css">
table{ width:800px; margin:auto; padding: 5px; font-size:12px; border:0px; background:#00CCFF;}
tr{ background:#fff;}
td{ padding: 5px;}
#title{ text-align:center;}
body{
background-image: url(img/bj.jpg);
background-size: cover;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
//连接MySQL数据库
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url="jdbc:mysql://localhost:3306/znjj";
String user="root";
String password="123456";
Connection conn = DriverManager.getConnection(url, user, password);
//Statement st = conn.createStatement();
//String sex = request.getParameter("sex");
float w1 = Float.parseFloat(request.getParameter("w1"));
float w2 = Float.parseFloat(request.getParameter("w2"));
String sql = "select * from xx where created>=? and created<=?";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
//preparedStatement.setString(1,sex);
preparedStatement.setFloat(1,w1);
preparedStatement.setFloat(2,w2);
ResultSet resultSet = preparedStatement.executeQuery();//执行sql语句用来返回单个 ResultSet 对象
resultSet.last();//移动到最后一条记录
%>
<center>
<h1>你要查询的环境监测表中共有
<font size="15" color="red"><%=resultSet.getRow()%></font>条数据符合您的查询条件</h1><br />
<table border="2" bgcolor="ccceee" width="650">
<tr>
<td>ID</td>
<td>温度</td>
<td>湿度</td>
<td>光照</td>
<td>时间</td>
</tr>
<%
resultSet.beforeFirst();
while (resultSet.next()){
%> <tr align="center">
<td><%=resultSet.getRow()%></td>
<td><%=resultSet.getString("wd")%></td>
<td><%=resultSet.getString("sd")%></td>
<td><%=resultSet.getString("gz")%></td>
<td><%=resultSet.getString("created")%></td>
</tr>
<%}%>
</table>
</center>
<%
if (resultSet!=null){
resultSet.close();
}
if (preparedStatement!=null){
preparedStatement.close();
}
if (conn!=null){
conn.close();
}
%>
<br />
<div align="center" >
<input class="blue.round:after" type ="button" value = "返回主页" onclick="window.location.href='main.html'">
</input></div>
<%
%>
</body>
</html>