ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

每周总结之第五周

2022-06-14 21:33:58  阅读:152  来源: 互联网

标签:总结 HttpServletRequest 每周 resp req HttpServletResponse 第五 import method


每周总结之第五周

 

package chezhanServlet;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
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;
import javax.servlet.http.HttpSession;

import Dao.DBUtil;
import Dao.Dao;
import Javabean.bean;

/**
* Servlet implementation class chezhanServlet
*/
@WebServlet("/chezhanServlet")
public class chezhanServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
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("login".equals(method)) {
login(req,resp);
}else if("addjiben".equals(method)) {
addjiben(req,resp);
}
else if("chaxun".equals(method)) {
chaxun(req,resp);
}
else if("chaxunzm".equals(method)) {
chaxunzm(req,resp);
}
else if("chaxunqishi".equals(method)) {
chaxunqishi(req,resp);
}
}

private void chaxunqishi(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
// TODO Auto-generated method stub
String qidian = req.getParameter("qidian");
String zhongdian = req.getParameter("zhongdian");
int qi;
int zhong;
int jingguochezhanshu;

String xianluhao =dao.searchzhandian(qidian);
qi=dao.searchqidian(qidian);
zhong=dao.searchzhongdian(zhongdian);
jingguochezhanshu=zhong-qi;
List<bean> list1 = dao.getallqishi(qi,zhong,xianluhao);
req.setAttribute("list1", list1);
req.setAttribute("jingguochezhanshu", jingguochezhanshu);
req.getRequestDispatcher("/xlxianshi.jsp").forward(req, resp);
}

private void chaxunzm(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
// TODO Auto-generated method stub
bean be=new bean();
be=null;
String zhanming = req.getParameter("zhanming");


List<bean> list1 = dao.getallzhanming(zhanming);
req.setAttribute("list1", list1);
req.getRequestDispatcher("/chaxun.jsp").forward(req, resp);
}

private void chaxun(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{bean be=new bean();
String xianluhao = req.getParameter("spid");
dao.searchxianlu(xianluhao);
be=dao.searchxianlu(xianluhao);
List<bean> list = dao.getallxianluhao(xianluhao);
req.setAttribute("list", list);
req.setAttribute("bean", be);
req.getRequestDispatcher("chaxun.jsp").forward(req, resp);
// req.getRequestDispatcher("/chaxun.jsp").forward(req, resp);
}
private void addjiben(HttpServletRequest req, HttpServletResponse resp) {
// TODO Auto-generated method stub

}

private void login(HttpServletRequest req, HttpServletResponse resp) {
// TODO Auto-generated method stub

}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub


}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");




// 将查询出来的用户信息保存到session对象中
HttpSession session = request.getSession();


}

 对于地铁查询 进行了 =页面展示输出 

标签:总结,HttpServletRequest,每周,resp,req,HttpServletResponse,第五,import,method
来源: https://www.cnblogs.com/wyq134214/p/16376446.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有