Java Jsp+Servlet+mysql实现的火车票查询预定系统(管理员/普通用户 功能:火车票查询、订票付款退票改签、火车票信息管理、线路管理、站点管理等)

您所在的位置:网站首页 列车车次查询系统 Java Jsp+Servlet+mysql实现的火车票查询预定系统(管理员/普通用户 功能:火车票查询、订票付款退票改签、火车票信息管理、线路管理、站点管理等)

Java Jsp+Servlet+mysql实现的火车票查询预定系统(管理员/普通用户 功能:火车票查询、订票付款退票改签、火车票信息管理、线路管理、站点管理等)

2024-03-24 08:56| 来源: 网络整理| 查看: 265

博客目录 JSP火车票预定查询系统实现功能截图技术点总结代码写在最后

JSP火车票预定查询系统

本系统是一套模拟12306网站的火车票一站式操作系统,普通用户可以查询、添加、改签火车票等,管理员可以管理线路、站点、车票等。

实现功能截图

详细功能点: 1、管理员/普通用户登录(注册) 2、修改密码 3、普通用户:查询火车票、订票、我的订单(付款、改签、退票) 4、管理员:管理员信息管理、会员信息管理、火车信息管理、站点信息管理、线路信息管理、车票信息管理、订票信息管理等

注册: 在这里插入图片描述 普通用户首页:在这里插入图片描述 火车票查询: 在这里插入图片描述 订票: 在这里插入图片描述 我的订单: 在这里插入图片描述

管理员登录: 在这里插入图片描述 管理员首页: 在这里插入图片描述 管理员火车信息管理: 在这里插入图片描述 站点信息管理: 在这里插入图片描述 线路信息管理: 在这里插入图片描述 车票信息管理: 在这里插入图片描述 订票信息管理: 在这里插入图片描述

技术点总结

jsp、Servlet jdk版本:1.7 tomcat: 7.0 数据库:mysql 开发工具:eclipse

项目包结构分类清晰: 在这里插入图片描述 (红色叉号为误报,emmm)

代码

model类“: Piao.java:

package dp.been; public class Piao { private int id; private int tid; private String tname; private String traintype; private int szdid; private String szdname; private int ezdid; private String ezdname; private String stime; private String pval; private String cxzh; private String ptype; private String yxsj; public int getId() { return id; } public void setId(int id) { this.id = id; } public int getTid() { return tid; } public void setTid(int tid) { this.tid = tid; } public String getTname() { return tname; } public void setTname(String tname) { this.tname = tname; } public String getTraintype() { return traintype; } public void setTraintype(String traintype) { this.traintype = traintype; } public int getSzdid() { return szdid; } public void setSzdid(int szdid) { this.szdid = szdid; } public String getSzdname() { return szdname; } public void setSzdname(String szdname) { this.szdname = szdname; } public int getEzdid() { return ezdid; } public void setEzdid(int ezdid) { this.ezdid = ezdid; } public String getEzdname() { return ezdname; } public void setEzdname(String ezdname) { this.ezdname = ezdname; } public String getStime() { return stime; } public void setStime(String stime) { this.stime = stime; } public String getPval() { return pval; } public void setPval(String pval) { this.pval = pval; } public String getCxzh() { return cxzh; } public void setCxzh(String cxzh) { this.cxzh = cxzh; } public String getPtype() { return ptype; } public void setPtype(String ptype) { this.ptype = ptype; } public String getYxsj() { return yxsj; } public void setYxsj(String yxsj) { this.yxsj = yxsj; } }

Traininfo.java:

package dp.been; public class Traininfo { private int id; private String tname; private String cz; private String znums; private String xcnums; private String traintype; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getTname() { return tname; } public void setTname(String tname) { this.tname = tname; } public String getCz() { return cz; } public void setCz(String cz) { this.cz = cz; } public String getZnums() { return znums; } public void setZnums(String znums) { this.znums = znums; } public String getXcnums() { return xcnums; } public void setXcnums(String xcnums) { this.xcnums = xcnums; } public String getTraintype() { return traintype; } public void setTraintype(String traintype) { this.traintype = traintype; } }

用户端servlet类: HandlePiaoSvlt.java:

package dp.svlt; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import dp.utils.DbConn; import net.sf.json.JSONObject; public class HandlePiaoSvlt extends HttpServlet { /** * Constructor of the object. */ public HandlePiaoSvlt() { super(); } /** * Destruction of the servlet. */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } /** * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html"); String id=request.getParameter("idi"); String flgs=request.getParameter("flgs"); JSONObject json=new JSONObject(); DbConn db=new DbConn(); if("fk".equals(flgs)){ int bls=db.deleteOrUpdate("update dpiao set lyflag='已付款' where id="+id); if(bls>0){ json.put("dt", 1); json.put("msg", "付款成功。"); }else{ json.put("dt", 0); json.put("msg", "fkerror:01"); } }else if("gq".equals(flgs)){//改签 int bls=db.deleteOrUpdate("delete from dpiao where id="+id); if(bls>0){ json.put("dt", 2); json.put("msg", "改签成功,请重新选票订票。"); }else{ json.put("dt", 0); json.put("msg", "fkerror:01"); } }else if("lp".equals(flgs)){ int bls=db.deleteOrUpdate("update dpiao set lyflag='已领票' where id="+id); if(bls>0){ json.put("dt", 1); json.put("msg", "领票成功。"); }else{ json.put("dt", 0); json.put("msg", "lperror:01"); } }else if("tp".equals(flgs)){ int bls=db.deleteOrUpdate("delete from dpiao where id="+id); if(bls>0){ json.put("dt", 1); json.put("msg", "退票成功。"); }else{ json.put("dt", 0); json.put("msg", "tperror:01"); } }else if("del".equals(flgs)){ int bls=db.deleteOrUpdate("delete from dpiao where id="+id); if(bls>0){ json.put("dt", 1); json.put("msg", "删除成功。"); }else{ json.put("dt", 0); json.put("msg", "tperror:01"); } }else{ json.put("dt", 0); } PrintWriter out = response.getWriter(); out.print(json.toString()); out.flush(); out.close(); } /** * Initialization of the servlet. * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } }

DpSvlt.java:

package dp.svlt; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import dp.utils.DbConn; import net.sf.json.JSONObject; public class DpSvlt extends HttpServlet { /** * Constructor of the object. */ public DpSvlt() { super(); } /** * Destruction of the servlet. */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } /** * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html"); HttpSession session=request.getSession(); Object userid =session.getAttribute("userid"); JSONObject json=new JSONObject(); if(userid==null){ json.put("msg", "请登录."); }else{ String pid=request.getParameter("pid"); if("".equals(pid)||pid==null){ json.put("msg", "error:01"); }else { DbConn db=new DbConn(); Object cidcard=db.getOnlyOne("select cidcard from cusinfo where id="+userid); boolean bl=db.insort("insert into dpiao(cidcard,pid,lyflag) values('"+cidcard+"',"+pid+",'待付款')"); if(!bl){ json.put("msg", 1); }else{ json.put("msg", "error:02"); } } } PrintWriter out = response.getWriter(); out.print(json.toString()); out.flush(); out.close(); } /** * Initialization of the servlet. * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } }

管理员端servlet: CkSvlt.java:

package dp.admin.svlt; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import dp.utils.HandleProperties; import net.sf.json.JSONObject; public class CkSvlt extends HttpServlet { /** * Constructor of the object. */ public CkSvlt() { super(); } /** * Destruction of the servlet. */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } /** * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //设置传输数据编码方式 request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); response.setContentType("text/html"); HttpSession session=request.getSession(); //获取使用者信息 Object userid=session.getAttribute("userid"); Object utype=session.getAttribute("utype"); //创建json对象 JSONObject json=new JSONObject(); String sql=request.getParameter("sql"); if(userid==null||utype==null){ json.put("msg", "请重新登陆"); }else{ HandleProperties hp=new HandleProperties(session,utype+""+userid); hp.setValue("sql", sql); json.put("msg", 1); } PrintWriter out=response.getWriter(); out.print(json.toString()); out.flush(); out.close(); } /** * Initialization of the servlet. * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } } 写在最后

码代码不容易,需要的同学可以参考学习,全部代码不能都贴出,如果需要可以+博主V交流获取(Code2Life2) 最后,别忘了一键三连哦



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3