今天做了什么:
完成了通过地铁线路号查询地铁站和通过地铁站chaxun线路
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import javax.swing.text.html.HTML;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@WebServlet("/point")
public class pointservlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
String point =request.getParameter("point");
Dao dao=new Dao();
String lineid="";
List<String> list=new ArrayList<>();
list=dao.pointselect(point);
for (String a:list) {
lineid=lineid+a+" , ";
}
request.setAttribute("lineid",lineid+"号线");
request.setAttribute("point",point);
request.getRequestDispatcher("point.jsp").forward(request,resp);
}
}
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@WebServlet("/line")
public class lineservlet extends HttpServlet {
@Override
protected void service(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
String line=request.getParameter("line");
String line1="";
Dao dao=new Dao();
List<position> list =dao.lineselect(line);
for (position point:list) {
//System.out.println(point.getPosition());
line1=line1+point.getPosition()+"-->";
request.setAttribute("line1",line1);
request.setAttribute("line",line+"号线");
}
request.getRequestDispatcher("line.jsp").forward(request,resp);
}
}
<%--<%–--%>
<%-- Created by IntelliJ IDEA.--%>
<%-- User: 29782--%>
<%-- Date: 2024/4/23--%>
<%-- Time: 17:07--%>
<%-- To change this template use File | Settings | File Templates.--%>
<%--–%>--%>
<%--<%@ page contentType="text/html;charset=UTF-8" language="java" %>--%>
<%--<html>--%>
<%--<head>--%>
<%-- <title>Title</title>--%>
<%--</head>--%>
<%--<body>--%>
<%--<form method="post" action="line">--%>
<%-- <input type="text" name="line">--%>
<%-- <button>提交</button><br>--%>
<%-- <div>${line}</div>--%>
<%--</form>--%>
<%--</body>--%>
<%--</html>--%>
<%--
Created by IntelliJ IDEA.
User: 29782
Date: 2024/3/31
Time: 19:32
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
<link href="layui/css/layui.css" rel="stylesheet">
</head>
<body>
<form method="post" action="line">
<div class="layui-form">
<input type="text" name="line" placeholder="请输入地铁线的名称" class="layui-input">
<hr class="ws-space-16">
</div>
<div class="layui-btn-container">
<button type="submit" class="layui-btn">提交</button>
</div>
</form>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
<link href="layui/css/layui.css" rel="stylesheet">
</head>
<body>
<br>
<br>
<table class="layui-table">
<colgroup>
<col width="150">
<col width="150">
<col>
</colgroup>
<thead>
<tr>
<th>地铁号</th>
<th>路线</th>
</tr>
</thead>
<tbody>
<tr>
<td>${line}</td>
<td>${line1}</td>
</tr>
</tbody>
</table>
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="layui/layui.js"></script>
</body>
</html>
<%--<%–--%>
<%-- Created by IntelliJ IDEA.--%>
<%-- User: 29782--%>
<%-- Date: 2024/4/24--%>
<%-- Time: 16:38--%>
<%-- To change this template use File | Settings | File Templates.--%>
<%--–%>--%>
<%--<%@ page contentType="text/html;charset=UTF-8" language="java" %>--%>
<%--<html>--%>
<%--<head>--%>
<%-- <title>Title</title>--%>
<%--</head>--%>
<%--<body>--%>
<%--<form method="post" action="point">--%>
<%-- <input type="text" name="point">--%>
<%-- <button>提交</button><br>--%>
<%-- <div>${lineid}</div>--%>
<%--</form>--%>
<%--</body>--%>
<%--</html>--%>
<%--
<%--
Created by IntelliJ IDEA.
User: 29782
Date: 2024/3/31
Time: 19:32
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
<link href="layui/css/layui.css" rel="stylesheet">
</head>
<body>
<form method="post" action="point">
<div class="layui-form">
<input type="text" name="point" placeholder="请输入站点的名称" class="layui-input">
<hr class="ws-space-16">
</div>
<div class="layui-btn-container">
<button type="submit" class="layui-btn">提交</button>
</div>
</form>
<br>
<br>
<table class="layui-table">
<colgroup>
<col width="150">
<col width="150">
<col>
</colgroup>
<thead>
<tr>
<th>地铁站</th>
<th>地铁号</th>
</tr>
</thead>
<tbody>
<tr>
<td>${point}</td>
<td>${lineid}</td>
</tr>
</tbody>
</table>
<script src="layui/layui.js"></script>
</body>
</html>
遇到了什么困难:
无
明天准备做什么:
准备学习迪杰斯特拉算法进行最短路径查找
代码量 300行