本周学习了软件工程相应简介
软件工程是把系统的, 有序的, 可量化的方法应用到软件的开发, 运营, 和维护上的过程。
软件工程包括下列领域:软件需求分析,软件设计,软件构建,软件测试和软件维护。
软件工程和下列的学科相关:计算机科学,计算机工程,管理学,数学, 项目管理学,质量管理,软件人体工学,系统工程,工业设计,和用户界面设计。
注册Github
并完成练习图表实现
创建城市类
package tryi;
public class ctiy{
private int num;
private String Date;
private String province;
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getDate() {
return Date;
}
public void setDate(String date) {
Date = date;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public ctiy() {}
public ctiy(String Date, String province,int num) {
this.Date=Date;
this.province=province;
this.num=num;
}
public ctiy( String Province,int num) {
this.province=Province;
this.num=num;
}
}
连接数据库
不展示
dao层
package tryi;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
public class Dao {
public List<ctiy> search(String Date) {
String s=Date+" 02:28:59";
String a="";
String sql = "select * from info where Date= '"+s+"' and City= '"+a+"'";
List<ctiy> list = new ArrayList<>();
Connection conn = DBUtil.getConn();
Statement state = null;
ResultSet rs = null;
try {
state = conn.createStatement();
rs = state.executeQuery(sql);
ctiy bean = null;
while (rs.next()) {
String province = rs.getString("Province");
int num = Integer.parseInt(rs.getString("Confirmed_num"));
bean = new ctiy(province,num);
list.add(bean);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, state, conn);
}
return list;
}
}
servlet层
package tryi;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/sServlet")
public class sServlet extends HttpServlet {
/**
* 特有id号
*/
private static final long serialVersionUID = 1L;
Dao dao = new Dao();
/**
* 方法选择
* @return
* @throws IOException
* @throws ServletException
*/
protected void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException
{
req.setCharacterEncoding("utf-8");
String method = req.getParameter("method");
if("root".equals(method)) {
yiqing(req,resp);
}
}
private void yiqing(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
req.setCharacterEncoding("utf-8");
String Date = req.getParameter("Date");
List<ctiy> yis = dao.search(Date);
req.setAttribute("yis", yis);
req.getRequestDispatcher("yiqing.jsp").forward(req, resp);
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询</title>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.code.js"></script>
<style>
.a{
width:300px;
height:240px;
position:absolute;
top:30%;
left:40%;
transform:translaet(-50%,-50%);
}
.c{
width:240px;
height:30px;
margin-left:30px;
}
.b{
margin-left:30px;
margin-top:45px;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="a">
<form action="sServlet?method=root" method="post" onsubmit="return check()">
<div class="b">
<label for="Date">日期:</label>
<input type="text" autofocus="autofocus" placeholder="请输入查询日期" id="Date" name="Date">
</div>
<div>
<input type="submit" class="c" value=" 查 询 ">
</div>
</form>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>疫情</title>
<!-- 使用单文件引入的方式使用ECharts.JS -->
<script src="echarts.js"></script>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div id="main" style="width: 1000px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
var arr = new Array();
var index = 0;
<c:forEach items="${yis}" var="yi">
arr[index++] = ${yi.num};
</c:forEach>
// 指定图表的配置项和数据
var option = {
title: {
text: '确诊人数'
},
tooltip: {
show: true
},
legend: {
data:['各省确诊人数']
},
xAxis : [
{
type : 'category',
data : [
<c:forEach items="${yis}" var="y">
["${y.province}"],
</c:forEach>
]
}
],
yAxis : [
{
type : 'value'
}
],
series : [
{
name:'Confirmed_num',
type:'bar',
data: arr
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
<div align="left">
<table class="tb">
<tr>
<td>省份</td>
<td>确诊人数</td>
</tr>
<c:forEach items="${yis}" var="item">
<tr>
<td>${item.province}</td>
<td>${item.num}</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
显示
来源:https://www.cnblogs.com/huiwuyan20/p/12453634.html