package main;
import Bean.SubwayBean;
import Dao.Sub;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
/**
*
* **/
@WebServlet("/SubwayMain")
public class SubwayMain extends HttpServlet {
@Override
public void init() throws ServletException {
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
String start = new String(req.getParameter("start_station").getBytes("ISO8859-1"),"UTF-8");
String end = new String(req.getParameter("end_station").getBytes("ISO8859-1"),"UTF-8");
try {
Sub sub = new Sub();
ArrayList<SubwayBean> arr = sub.ArrayTransferStation(start,end);
if (arr!=null){
req.setAttribute("routeMain", arr);
req.getRequestDispatcher("/bestresult.jsp").forward(req, resp);
}else {
req.getRequestDispatcher("/fail.jsp").forward(req, resp);
}
}catch (Exception e){
e.printStackTrace();
}finally {
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
@Override
public void destroy() {
}
}
SubwayStation.java
package main;
import Bean.DB;
import Dao.Sub;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet("/SubwayStation")
public class SubwayStation extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
String na = req.getParameter("name");
DB db = new DB();
Sub sub = new Sub();
String line = sub.LineStation(na);
if(line!=null){
req.setAttribute("routeStation",line);
req.getRequestDispatcher("/nameresult.jsp").forward(req,resp);
}else{
req.getRequestDispatcher("/fail.jsp").forward(req,resp);
}
}
@Override
protected void doPost(HttpServletRequest rep,HttpServletResponse resp)throws ServletException,IOException{
doGet(rep, resp);
}
@Override
public void init() throws ServletException{
}
@Override
public void destroy(){
}
}
mysub_style.css
/* 表格样式 */
table {
border-collapse: collapse;
border-spacing: 0;
}
/* 超链接样式 */
a {
color: #5086a5;
text-decoration: none;
font-size: 12px;
}
a:hover {
text-decoration: underline;
}
a:visited {
color: #5086a5;
}
/* Tab 相关样式 */
#tabDiv {
width: 600px;
margin: 1em auto;
padding: 10px;
border: 1px solid #b2c9d3;
background: #ffffff;
}
#tabsHead {
padding-left: 0;
height: 26px;
background-color: #e8f7fc;
font-size: 1em;
margin: 1px 0;
color: #5086a5;
line-height: 26px;
}
.curtab,
.tabs {
padding: 0 10px;
float: left;
cursor: pointer;
}
.curtab {
border-right: 1px solid #b2c9d3;
font-weight: bold;
background: #ffffff;
}
.tabs {
border-right: 1px solid #c1d8e0;
font-weight: normal;
}
/* 段落样式 */
p {
font-size: 12pt;
text-indent: 2em;
}
/* 列表样式 */
li {
border-bottom: 1px solid #EEE;
height: 25px;
font-family: "宋体";
font-size: 12pt;
}
/* 修改并新增 - 盒子样式 */
.box {
width: 140px;
height: 140px;
margin: 50px auto; /* 调整外边距为50px */
position: relative;
border: 1px solid #b2c9d3; /* 添加边框样式 */
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
}
.box > div {
width: 100%;
height: 100%;
position: absolute;
border-radius: 50%;
transition: all 2s linear;
backface-visibility: hidden;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2023-05-08 c++打卡练习(22)