结队作业psp0级报告
今天完成了web端开发,进行手机端开发
1.1需求描述:
开发一个地铁查询系统,方便人们更加便利的出行
1.2估计开发时间
三天
1.3填写项目数据
车站信息和线路信息储存在数据库中,当用户进行指定查询输出相关信息
1.4填写时间记录日志
学生:贾湛秋,郭子锴 日期:2023.3.17
教师:王建民 课程:软件工程
|
日期 |
开始时间 |
结束时间 |
中断时间 |
净时间 |
活动 |
备注 |
C |
U |
|
3.15 |
18:00 |
21:00 |
|
3小时 |
数据库信息的录入和基本页面的编写 |
设计数据库的结构 |
|
|
|
3.16 |
18:00 |
22:00 |
|
4小时 |
调试程序 |
编写相关功能的实现和servlet传值 |
|
|
|
3.17 |
18:00 |
23:00 |
|
5小时 |
调试程序 |
完善功能,优化界面 |
|
|
- 开发
2.1设计程序
通过算法实现对路径的查询,并传值到web端页面中,在运行web端的程序,弹出相关线路信息,并将该list提交到另外一个jsp中进行显示。
2.2设计实现
源代码(只展示重要部分):
left.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="menu.css">
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0">
<div class="left">
<center><img src="subway.jpg" width="100dp" height="100dp"></center>
<br>
<a href="chaxun.jsp?way=1" target="rightframe">线路查询</a>
<br>
<a href="chaxun.jsp?way=2" target="rightframe">站点查询</a>
<br>
<a href="chaxun.jsp?way=3" target="rightframe">最短线路查询</a>
<br>
<a href="chaxun.jsp?way=4" target="rightframe">最少换乘查询</a>
<br>
</div>
</body>
</html>
chaxun.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<link rel="stylesheet" href="kk.css">
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginheight="0" marginwidth="0" background="bjt.jpg">
<%
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
String way=request.getParameter("way");
if(way.equals("1")){
%>
<form action="Servlet?method=yy&key=1" method="post">
<input type="text" name="linename" placeholder="线路名称">
<input type="submit" value="查询">
</form>
<%
}
else if(way.equals("2")){
%>
<form action="Servlet?method=yy&key=2" method="post">
<input type="text" name="pos" placeholder="站点名称">
<input type="submit" value="查询">
</form>
<%
}
else if(way.equals("3")){
%>
<form action="Servlet?method=yy&key=3" method="post">
<input type="text" name="start" placeholder="起点">
<input type="text" name="end" placeholder="终点">
<input type="submit" value="查询">
</form>
<%
}
else if(way.equals("4")){
%>
<form action="Servlet?method=yy&key=4" method="post">
<input type="text" name="start" placeholder="起点">
<input type="text" name="end" placeholder="终点">
<input type="submit" value="查询">
</form>
<%
}
%>
</body>
</html>
DButil类
package util;
import java.sql.*;
public class DButil {
public static Connection getConn() throws ClassNotFoundException {
Connection connection=null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ditie", "root", "byc666");
}catch(Exception e){
e.printStackTrace();
}
return connection;
}
public static void closeall(Connection connection, PreparedStatement preparedStatement, ResultSet resultSet){
try{
if(resultSet!=null)
resultSet.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
try{
if(preparedStatement!=null)
preparedStatement.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
try{
if(connection!=null)
connection.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
}
Servlet
package service;
import bean.base;
import bean.changesub;
import dao.Dao;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
public class Servlet extends HttpServlet {
Dao dao=new Dao();
public void service(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
String method= request.getParameter("method");
if(method.equals("yy")){
yy(request,response);
}
}
public void yy(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException {
request.setCharacterEncoding("UTF-8");
String key=request.getParameter("key");
if(key.equals("1")){
String linename=request.getParameter("linename");
if(dao.confirmline(linename)) {
ArrayList<base> lines = dao.getline1(linename);
request.setAttribute("lines", lines);
request.setAttribute("key", "1");
request.getRequestDispatcher("list.jsp").forward(request, response);
}
else{
request.setAttribute("message","输入的线路不存在");
request.getRequestDispatcher("hello.jsp").forward(request,response);
}
}else if(key.equals("2")){
String linename=request.getParameter("pos");
if(dao.confirmstation(linename)) {
ArrayList<base> lines = dao.getline2(linename);
request.setAttribute("lines", lines);
request.setAttribute("key", "2");
request.getRequestDispatcher("list.jsp").forward(request, response);
}
else{
request.setAttribute("message","输入的车站不存在");
request.getRequestDispatcher("hello.jsp").forward(request,response);
}
}
else if(key.equals("3")){
String start=request.getParameter("start");
String end=request.getParameter("end");
if(dao.confirmstation(start)&&dao.confirmstation(end)){
ArrayList<changesub>lines=dao.getline3(start,end);
if(lines.size()<=0){
request.setAttribute("message","无换乘路线");
request.getRequestDispatcher("hello.jsp").forward(request,response);
}
request.setAttribute("lines",lines);
request.setAttribute("key","3");
request.setAttribute("changdu","共查询到:"+lines.size()+"条线路");
request.getRequestDispatcher("list.jsp").forward(request,response);
}
else{
request.setAttribute("message","输入的车站不存在");
request.getRequestDispatcher("hello.jsp").forward(request,response);
}
}
else if(key.equals("4")){
String start=request.getParameter("start");
String end=request.getParameter("end");
if(dao.confirmstation(start)&&dao.confirmstation(end)){
ArrayList<changesub>line=dao.getline3(start,end);
if(line.size()<=0){
request.setAttribute("message","无换乘路线");
request.getRequestDispatcher("hello.jsp").forward(request,response);
}
ArrayList<changesub> lines=dao.getminchang(line);
request.setAttribute("lines",lines);
request.setAttribute("key","3");
request.setAttribute("changdu","共查询到:"+lines.size()+"条最短换乘线路");
request.getRequestDispatcher("list.jsp").forward(request,response);
}
else{
request.setAttribute("message","输入的车站不存在");
request.getRequestDispatcher("hello.jsp").forward(request,response);
}
}
}
}
2.3编译程序,修复并记录所发现的bug,并填写缺陷记录日志
学生:贾湛秋
日期:2023.3.17
老师:王建民
程序号:1
|
日期 |
编号 |
类型 |
引入阶段 |
排除阶段 |
修复时间 |
修复缺陷 |
|
3.17 |
1 |
20 |
编码 |
编译 |
1h |
|
|
当查询线路不存在时,不显示东西,通过进入新页面解决 |
||||||
|
日期 |
编号 |
类型 |
引入阶段 |
排除阶段 |
修复时间 |
修复缺陷 |
|
3.17 |
2 |
20 |
编码 |
编译 |
10min |
|
|
当起点和终点相同时,不显示线路,通过进入新页面并显示信息解决 |
||||||
- 总结
本程序大约在花了四的时间完成,在开发过程中,遇到的bug有查询线路出错,对js和css的了解还不够,但是已经基本完成了项目开发所需要的要求。


浙公网安备 33010602011771号