码迷,mamicode.com
首页 > 其他好文 > 详细

第二周项目功能实现

时间:2020-07-23 15:44:11      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:rap   win   jsp   w3c   ring   遇到   mes   each   spring   

本周完成项目情况:

1.前台功能模块:

  a.票务查询

  b.车票销售

  c.改签

  d.退票

2.后台功能模块

  a.票务管理

  b.信息发布

  c.订单统计

  d.销售情况查询

二、核心源码:

实体类:com.hp.model

技术图片
 1 package com.hp.model;
 2 
 3 public class Ticket {
 4     private Integer tid;//编号
 5     private String ticketNo;//车次
 6     private String startAddress;//出发地
 7     private String endAddress;//目的地
 8     private Integer price;//价格
 9     private String time;//时间
10     private String manned;//车载人数
11     private Integer ticketCount;//余票
12     private String delstatus;
13     public Integer getTid() {
14         return tid;
15     }
16     public void setTid(Integer tid) {
17         this.tid = tid;
18     }
19     public String getTicketNo() {
20         return ticketNo;
21     }
22     public void setTicketNo(String ticketNo) {
23         this.ticketNo = ticketNo;
24     }
25     public String getStartAddress() {
26         return startAddress;
27     }
28     public void setStartAddress(String startAddress) {
29         this.startAddress = startAddress;
30     }
31     public String getEndAddress() {
32         return endAddress;
33     }
34     public void setEndAddress(String endAddress) {
35         this.endAddress = endAddress;
36     }
37     public Integer getPrice() {
38         return price;
39     }
40     public void setPrice(Integer price) {
41         this.price = price;
42     }
43     public String getTime() {
44         return time;
45     }
46     public void setTime(String time) {
47         this.time = time;
48     }
49     
50     
51     public String getManned() {
52         return manned;
53     }
54     public void setManned(String manned) {
55         this.manned = manned;
56     }
57     public Integer getTicketCount() {
58         return ticketCount;
59     }
60     public void setTicketCount(Integer ticketCount) {
61         this.ticketCount = ticketCount;
62     }
63     public String getDelstatus() {
64         return delstatus;
65     }
66     public void setDelstatus(String delstatus) {
67         this.delstatus = delstatus;
68     }
69     
70     
71 }
Ticket
技术图片
 1 package com.hp.model;
 2 
 3 import java.util.Date;
 4 
 5 public class Order {
 6     private Integer orderId;
 7     private Date orderTime;//订单时间
 8     private String travleTime;//乘车日期
 9     private Userinfo userinfo;//用户
10     private Ticket ticket;//车票
11     private String delstatus;
12     private Integer tcount;
13     
14     
15     public Integer getTcount() {
16         return tcount;
17     }
18     public void setTcount(Integer tcount) {
19         this.tcount = tcount;
20     }
21     public Integer getOrderId() {
22         return orderId;
23     }
24     public void setOrderId(Integer orderId) {
25         this.orderId = orderId;
26     }
27     
28     public Date getOrderTime() {
29         return orderTime;
30     }
31     public void setOrderTime(Date orderTime) {
32         this.orderTime = orderTime;
33     }
34     
35     public String getTravleTime() {
36         return travleTime;
37     }
38     public void setTravleTime(String travleTime) {
39         this.travleTime = travleTime;
40     }
41     public Userinfo getUserinfo() {
42         return userinfo;
43     }
44     public void setUserinfo(Userinfo userinfo) {
45         this.userinfo = userinfo;
46     }
47     public Ticket getTicket() {
48         return ticket;
49     }
50     public void setTicket(Ticket ticket) {
51         this.ticket = ticket;
52     }
53     public String getDelstatus() {
54         return delstatus;
55     }
56     public void setDelstatus(String delstatus) {
57         this.delstatus = delstatus;
58     }
59     
60     
61 
62 }
Order

Dao接口:

技术图片
 1 package com.hp.dao;
 2 
 3 import java.util.List;
 4 
 5 import org.apache.ibatis.annotations.Param;
 6 
 7 import com.hp.model.Ticket;
 8 
 9 public interface TicketDao {
10     
11     //根据起点和终点查询
12     List<Ticket> findByAddress(@Param("startAddress")String startAddress,@Param("endAddress")String endAddress );
13     //查询所有车票
14     List<Ticket> selectAll();
15     //添加车票信息
16     Integer addTicket(Ticket ticket);
17     //删除车票信息
18     Integer deleteTicket(Integer tid);
19     //修改车票信息
20     Integer updateTicket(Ticket ticket);
21     //根据id查询车票信息
22     Ticket findTicketById(Integer tid);
23 }
TicketDao
技术图片
 1 package com.hp.dao;
 2 
 3 import java.util.List;
 4 
 5 import org.apache.ibatis.annotations.Param;
 6 
 7 import com.hp.model.Order;
 8 
 9 public interface OrderDao {
10     
11     //添加订单
12     Integer addOrder(Order order);
13     //查询当前用户下的所有订单
14     List<Order> findAllOrders(@Param(value = "userId")Integer userId);
15     //根据车票编号查找订单
16     Order findOrderById(Order order);
17     //删除订单
18     Integer deleteOrder(Integer orderId);
19     //修改订单
20     Integer updateOrder(Order order);
21     //统计订单
22     List<Order> orderCount();
23 }
OrderDao

Mapper映射文件:

技术图片
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE mapper
 3     PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 4     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 5 
 6 <mapper namespace="com.hp.dao.TicketDao">
 7      
 8      <select id="findByAddress" resultType="com.hp.model.Ticket">
 9          select * from ticket where startAddress=#{startAddress} and endAddress=#{endAddress}
10      </select>
11      <select id="selectAll" resultType="com.hp.model.Ticket">
12          select * from ticket where delstatus=1
13      </select>
14      <select id="findTicketById" resultType="com.hp.model.Ticket">
15          select * from ticket where tid=#{tid} and delstatus=1
16      </select>
17      <insert id="addTicket" parameterType="com.hp.model.Ticket">
18          insert into ticket(ticketNo,startAddress,endAddress,price,time,manned,ticketCount,delstatus)
19          values(#{ticketNo},#{startAddress},#{endAddress},#{price},#{time},#{manned},#{ticketCount},1)
20      </insert>
21      <update id="deleteTicket" >
22          update ticket set delstatus=0 where tid=#{tid}
23      </update>
24      <update id="updateTicket" >
25          update ticket set
26              ticketNo=#{ticketNo},
27               startAddress=#{startAddress},
28               endAddress=#{endAddress},
29               price=#{price},
30               time=#{time},
31               manned=#{manned},
32               ticketCount=#{ticketCount}
33          where tid=#{tid} and delstatus=1
34      </update>
35      
36      
37 </mapper>
TicketDaoMapper.xml
技术图片
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE mapper
 3     PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 4     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 5 
 6 <mapper namespace="com.hp.dao.OrderDao">
 7      <resultMap type="com.hp.model.Order" id="orderMap">
 8          <id property="orderId" column="orderId" />
 9         <result property="orderTime" column="orderTime" javaType="java.util.Date"/>
10         <result property="travleTime" column="travleTime"/>
11         <result property="delstatus" column="delstatus" />
12         <result property="tcount" column="tcount" />
13      <association property="userinfo" javaType="com.hp.model.Userinfo">
14           <id property="userId" column="userId" />
15         <result property="uname" column="uname" />
16         <result property="upass" column="upass" />
17         <result property="urealname" column="urealname" />
18         <result property="tel" column="tel" />
19         <result property="cardId" column="cardId" />
20         <result property="type" column="type" />
21         <result property="deleteStatus" column="deleteStatus" />
22      </association>
23      <association property="ticket" javaType="com.hp.model.Ticket">
24          <id property="tid" column="tid"/>
25          <result property="ticketNo" column="ticketNo" />
26         <result property="startAddress" column="startAddress" />
27         <result property="endAddress" column="endAddress" />
28         <result property="price" column="price" />
29         <result property="time" column="time" />
30         <result property="manned" column="manned" />
31         <result property="ticketCount" column="ticketCount" />
32         <result property="delstatus" column="delstatus" />
33      </association>
34      </resultMap>
35      
36      
37      <select id="findAllOrders" resultType="com.hp.model.Order" resultMap="orderMap">
38          select * from torder o 
39          inner join userinfo u
40          inner join ticket t
41          where o.userId =u.userId and o.ticketId=t.tid 
42          and o.delstatus=1 and u.deletestatus=1 and t.delstatus=1
43          <if test="userId!=null and userId!=‘‘">
44              and o.userId=#{userId}
45          </if>
46      </select>
47      <select id="orderCount"  resultMap="orderMap">
48        select count(*) tcount,t.*,o.* from torder  o
49         inner join ticket t
50         where o.delstatus=1 and t.delstatus and o.ticketId=t.tid
51         group by o.ticketId
52      </select>
53      
54      
55      
56      <insert id="addOrder" parameterType="com.hp.model.Order">
57          insert into torder (ticketId,userId,orderTime,travleTime,delstatus) 
58          values(#{ticket.tid},#{userinfo.userId},now(),#{travleTime},1)
59      </insert>
60      <select id="findOrderById" parameterType="com.hp.model.Order" resultType="com.hp.model.Order">
61          select * from torder where ticketId=#{ticket.tid} and travleTime=#{travleTime} and delstatus=1
62      </select>
63      <update id="deleteOrder">
64          update torder set delstatus=0 where orderId=#{orderId}
65      </update>
66      <update id="updateOrder" parameterType="com.hp.model.Order">
67          update torder set ticketId=#{ticket.tid},orderTime=now(),travleTime=#{travleTime}
68          where orderId=#{orderId} and delstatus=1
69      </update>
70      
71 </mapper>
OrderDaoMapper.xml

业务层Service:

技术图片
 1 package com.hp.service;
 2 
 3 import java.util.List;
 4 
 5 import org.springframework.beans.factory.annotation.Autowired;
 6 import org.springframework.stereotype.Service;
 7 
 8 import com.hp.dao.TicketDao;
 9 import com.hp.model.Ticket;
10 @Service
11 public class TicketServiceImpl implements TicketService {
12     @Autowired
13     private TicketDao ticketDao;
14 
15     @Override
16     public List<Ticket> findByAddress(String startAddress, String endAddress) {
17         return ticketDao.findByAddress(startAddress, endAddress);
18     }
19 
20     @Override
21     public List<Ticket> selectAll() {
22         return ticketDao.selectAll();
23     }
24 
25     @Override
26     public Integer addTicket(Ticket ticket) {
27         return ticketDao.addTicket(ticket);
28     }
29 
30     @Override
31     public Integer deleteTicket(Integer tid) {
32         return ticketDao.deleteTicket(tid);
33     }
34 
35     @Override
36     public Integer updateTicket(Ticket ticket) {
37         return ticketDao.updateTicket(ticket);
38     }
39 
40     @Override
41     public Ticket findTicketById(Integer tid) {
42         return ticketDao.findTicketById(tid);
43     }
44 
45 }
TicketServiceImpl
技术图片
 1 package com.hp.service;
 2 
 3 import java.util.List;
 4 
 5 import org.springframework.beans.factory.annotation.Autowired;
 6 import org.springframework.stereotype.Service;
 7 
 8 import com.hp.dao.OrderDao;
 9 import com.hp.model.Order;
10 
11 @Service
12 public class OrderServiceImpl implements OrderService {
13     @Autowired
14     private OrderDao orderDao;
15 
16     @Override
17     public Integer addOrder(Order order) {
18         return orderDao.addOrder(order);
19     }
20 
21     @Override
22     public List<Order> findAllOrders(Integer userId) {
23         return orderDao.findAllOrders(userId);
24     }
25 
26     @Override
27     public Order findOrderById(Order order) {
28         return orderDao.findOrderById(order);
29     }
30 
31     @Override
32     public Integer deleteOrder(Integer userId) {
33         return orderDao.deleteOrder(userId);
34     }
35 
36     @Override
37     public Integer updateOrder(Order order) {
38         return orderDao.updateOrder(order);
39     }
40 
41     @Override
42     public List<Order> orderCount() {
43         return orderDao.orderCount();
44     }
45 
46 }
OrderServiceImpl

控制层 Controller

技术图片
 1 package com.hp.controller;
 2 
 3 import java.util.List;
 4 
 5 import javax.servlet.http.HttpSession;
 6 
 7 import org.springframework.beans.factory.annotation.Autowired;
 8 import org.springframework.stereotype.Controller;
 9 import org.springframework.web.bind.annotation.RequestMapping;
10 
11 import com.hp.model.Ticket;
12 import com.hp.service.TicketServiceImpl;
13 
14 @Controller
15 public class TicketController {
16     @Autowired
17     private TicketServiceImpl ticketService;
18     //前台根据起始站和终点站查询
19     @RequestMapping(value="/findByAddress",produces="text/plain;charset=utf-8")
20     public String findByAddress(HttpSession session,String startAddress,String  endAddress){
21      List<Ticket> list = ticketService.findByAddress(startAddress, endAddress);
22         if (list.size()>0) {
23             session.setAttribute("ticketList", list);
24             return "ticketAll.jsp";
25         }
26         return "redirect:/selectAllTicket?opr=qticket";
27     }
28     //前后台查询所有票务信息
29     @RequestMapping(value="/selectAllTicket",produces="text/plain;charset=utf-8")
30     public String selectAllTicket(HttpSession session,String opr){
31      List<Ticket> list = ticketService.selectAll();
32         if (list.size()>0) {
33             session.setAttribute("ticketList", list);
34             if(opr.equals("qticket")){
35                 return "ticketAll.jsp";
36             }else{
37                 return "adminTicket.jsp";
38             }
39             
40         }
41         return null;
42     }
43     //后台添加票务信息
44     @RequestMapping(value="/addTicket",produces="text/plain;charset=utf-8")
45     public String addTicket(Ticket ticket){
46         Integer addTicket = ticketService.addTicket(ticket);
47         if (addTicket>0) {
48             return "redirect:/selectAllTicket?opr=aticket";
49         }
50         return "addTicket.jsp";
51     }
52     
53     //后台删除票务信息
54     @RequestMapping(value="/deleteTicket",produces="text/plain;charset=utf-8")
55     public String deleteTicket(Integer tid){
56         Integer deleteTicket = ticketService.deleteTicket(tid);
57         if (deleteTicket>0) {
58             return "redirect:/selectAllTicket?opr=aticket";
59         }
60         return "adminTicket.jsp";
61     }
62     //后台根据id查询票务信息
63     @RequestMapping(value="/findTicketById",produces="text/plain;charset=utf-8")
64     public String findTicketById(HttpSession session,Integer tid,String opr){
65         Ticket findTicketById = ticketService.findTicketById(tid);
66         if (findTicketById!=null) {
67             session.setAttribute("findTickes", findTicketById);
68             if (opr.equals("at")) {
69                 return "updateTicket.jsp";
70             }else{
71                 return "orderTicket.jsp";
72             }
73             
74         }
75         return "adminTicket.jsp";
76     }
77      //后台修改票务信息
78     @RequestMapping(value="/updateTicket",produces="text/plain;charset=utf-8")
79     public String updateTicket(Ticket ticket){
80         Integer updateTicket = ticketService.updateTicket(ticket);
81         if (updateTicket>0) {
82             return "redirect:/selectAllTicket?opr=aticket";
83         }
84         return "adminTicket.jsp";
85     }
86 }
TicketController
技术图片
  1 package com.hp.controller;
  2 
  3 import java.util.List;
  4 
  5 import javax.servlet.http.HttpSession;
  6 
  7 import org.springframework.beans.factory.annotation.Autowired;
  8 import org.springframework.stereotype.Controller;
  9 import org.springframework.web.bind.annotation.RequestMapping;
 10 
 11 import com.hp.model.Order;
 12 import com.hp.model.Ticket;
 13 import com.hp.model.Userinfo;
 14 import com.hp.service.OrderService;
 15 import com.hp.service.TicketServiceImpl;
 16 
 17 @Controller
 18 public class OrderController {
 19     @Autowired
 20     private OrderService orderService;
 21     @Autowired
 22     private TicketServiceImpl ticketService;
 23        //添加订单
 24         @RequestMapping(value="/addOrder",produces="text/plain;charset=utf-8")
 25         public String addOrder(Order order){
 26             Order findOrderById = orderService.findOrderById(order);
 27             if(findOrderById == null){
 28                 Integer addOrder = orderService.addOrder(order);
 29                 Ticket ticket = ticketService.findTicketById(order.getTicket().getTid());
 30                 ticket.setTicketCount(ticket.getTicketCount()-1);
 31                 Integer updateTicket = ticketService.updateTicket(ticket);
 32                 if(addOrder > 0 && updateTicket>0){
 33                     return "redirect:/findAllOrders";
 34                 }
 35             }
 36             
 37             return "orderTicket.jsp";
 38         }
 39         //查询当前用户下的订单
 40         @RequestMapping(value="/findAllOrders",produces="text/plain;charset=utf-8")
 41         public String findAllOrdersByUserId(HttpSession session){
 42             Userinfo userinfo = (Userinfo)session.getAttribute("user");
 43             List<Order> findAllOrders = orderService.findAllOrders(userinfo.getUserId());
 44             if(findAllOrders != null){
 45                 session.setAttribute("orderList", findAllOrders);
 46                 return "searchOrder.jsp";
 47             }
 48             return "orderTicket.jsp";
 49         }
 50         //管理员查询所有订单信息
 51         @RequestMapping(value="/adminfindAllOrders",produces="text/plain;charset=utf-8")
 52         public String findAllOrders(HttpSession session){
 53             List<Order> findAllOrders = orderService.findAllOrders(null);
 54             if(findAllOrders != null){
 55                 session.setAttribute("ordersList", findAllOrders);
 56                 return "adminOrderList.jsp";
 57             }
 58             return "admin.jsp";
 59         }
 60         //退票
 61         @RequestMapping(value="/deleteOrder",produces="text/plain;charset=utf-8")
 62         public String deleteOrder(Order order){
 63             Integer deleteOrder = orderService.deleteOrder(order.getOrderId());//删除订单
 64             Ticket ticket = ticketService.findTicketById(order.getTicket().getTid());
 65             ticket.setTicketCount(ticket.getTicketCount()+1);
 66             Integer updateTicket = ticketService.updateTicket(ticket);
 67             if (deleteOrder>0 && updateTicket>0) {
 68                 
 69                 return "redirect:/findAllOrders?userId="+order.getUserinfo().getUserId();
 70             }
 71             return  "orderTicket.jsp";
 72         }
 73         
 74         //跳转改签页面
 75         @RequestMapping(value="/findAllTickets",produces="text/plain;charset=utf-8")
 76         public String findAllTickets(HttpSession session,Order order){
 77              List<Ticket> list = ticketService.selectAll();
 78                 if (list.size()>0) {
 79                     session.setAttribute("ord", order);
 80                     session.setAttribute("ticketsList", list);
 81                         return "updateOrder.jsp";
 82                     }
 83                 return null;
 84             
 85         }
 86         //改签
 87         @RequestMapping(value="/updateOrder",produces="text/plain;charset=utf-8")
 88         public String updateOrder(HttpSession session,Order order){
 89              Integer updateOrder = orderService.updateOrder(order);
 90              Order ord = (Order)session.getAttribute("ord");//改签前
 91              Ticket ticket = ticketService.findTicketById(ord.getTicket().getTid());
 92              ticket.setTicketCount(ticket.getTicketCount()+1);
 93              Integer updateTicket = ticketService.updateTicket(ticket);
 94              //改签后
 95              Ticket tck = ticketService.findTicketById(order.getTicket().getTid());
 96              tck.setTicketCount(tck.getTicketCount()-1);
 97              Integer updateTicket2 = ticketService.updateTicket(tck);
 98              if (updateOrder>0 &&updateTicket>0 && updateTicket2>0) {
 99                     return "redirect:/findAllOrders";
100                 }
101              return "updateOrder.jsp";
102             
103         }
104         
105         //统计订单
106         @RequestMapping(value="/OrderCount",produces="text/plain;charset=utf-8")
107         public String OrderCount(HttpSession session){
108             List<Order> orderCount = orderService.orderCount();
109             if (orderCount!=null) {
110                 session.setAttribute("orderCoun", orderCount);
111                 return "adminOrderCount.jsp";
112             }
113             return "main.jsp";
114         }
115         
116         
117 }
OrderController

技术图片

 

技术图片

技术图片
  1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
  2 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3 <!DOCTYPE html >
  4 <html>
  5 <head>
  6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7 <title>主页面</title>
  8 <link href="images/style.css" rel="stylesheet" type="text/css" />
  9 <link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
 10 <script type="text/javascript" src="js/jquery.js"></script>
 11 <script type="text/javascript" src="js/bootstrap.js"></script>
 12 <style type="text/css">
 13 body {
 14     background:#FFF
 15 }
 16 </style>
 17 </head>
 18 <script type="text/javascript">
 19     function ding(){
 20         alert("游客,请登录");
 21         window.open("qlogin.jsp","_parent");
 22     }
 23     function order(tid){
 24         window.location.href="findTicketById?opr=qt&tid="+tid;
 25     }
 26 </script>
 27 <body>
 28 <div id="contentWrap">
 29 <div class="pageTitle"></div>
 30 <div class="pageColumn">
 31    <div class="container">
 32     <div class="row clearfix">
 33         <div class="col-md-12 column">
 34             <form class="form-inline" role="form" action="findByAddress" method="post">
 35                 <div class="form-group">
 36                     <label class="sr-only" for="name">名称</label>
 37                     <input type="text" class="form-control" id="start"  name="startAddress" 
 38                            placeholder="请输入出发地">
 39                 </div>
 40                 <div class="form-group">
 41                     <label class="sr-only" for="name">名称</label>
 42                     <input type="text" class="form-control" id="end" name="endAddress"
 43                            placeholder="请输入目的地">
 44                 </div>
 45                 
 46                 <button type="submit" class="btn btn-default">查询</button>
 47             </form>
 48                     
 49         
 50             <table class="table table-bordered table-hover" style="margin-top: 10px">
 51                 <thead>
 52                     <tr>
 53                         <th>
 54                             车次编号
 55                         </th>
 56                         <th>
 57                             起点站
 58                         </th>
 59                         <th>
 60                             终点站
 61                         </th>
 62                         <th>
 63                             时间
 64                         </th>
 65                         <th>
 66                             价格
 67                         </th>
 68                         <th>
 69                             车载人数
 70                         </th>
 71                         <th>
 72                             余票
 73                         </th>
 74                         <th>
 75                             操作
 76                         </th>
 77                     </tr>
 78                 </thead>
 79                 <tbody>
 80                  <c:forEach var="ticket" items="${ticketList }" >
 81                      <tr>
 82                         <td>${ticket.ticketNo}</td>
 83                         <td>${ticket.startAddress }</td>
 84                         <td>${ticket.endAddress }</td>
 85                         <td>${ticket.time }</td>
 86                         <td>¥${ticket.price }</td>
 87                         <td>${ticket.manned } 人</td>
 88                         <td>${ticket.ticketCount } 张</td>
 89                         <td>
 90                             <c:if test="${not empty user.uname }">
 91                                  <c:if test="${ticket.ticketCount>0}">
 92                                     <input type="button" onclick="order(${ticket.tid})"   value="订票" style="width: 50px;height:30px;background:#9BD8F7;color: red;"/>  
 93                                  </c:if>
 94                                   <c:if test="${ticket.ticketCount == 0}">
 95                                     <input type="button" disabled="disabled"  value="订票" style="width: 50px;height:30px;background:gray;color: white;"/>  
 96                                  </c:if>
 97                         </c:if>
 98                         <c:if test="${empty user.uname }">
 99                                 <input type="button" onclick="ding()"   value="订票" style="width: 50px;height:30px;background:#9BD8F7;color: red;"/>  
100                         </c:if>
101                         </td>
102                      </tr>
103                  </c:forEach>
104                     
105                 </tbody>
106             </table>
107         </div>
108     </div>
109 </div>
110 </div></div>
111 </body>
112 </html>
ticketAll.jsp

技术图片

 

技术图片
 1 <%@ page language="java" contentType="text/html; charset=utf-8"
 2     pageEncoding="utf-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4 <html xmlns="http://www.w3.org/1999/xhtml">
 5 <head>
 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 7 <title>添加票务信息</title>
 8 <link href="css/style.css" rel="stylesheet" type="text/css" />
 9 </head>
10 
11 <body>
12   <form action="addTicket" method="post">
13     <div class="place">
14     <span>位置:</span>
15     <ul class="placeul">
16     <li><a href="#">票务管理</a></li>
17     <li><a href="#">添加票务信息</a></li>
18     </ul>
19     </div>
20     
21     <div class="formbody">
22     
23     <div class="formtitle"><span>添加票务信息</span></div>
24     
25     <ul class="forminfo">
26     <li><label>车次编号</label><input name="ticketNo" type="text" class="dfinput" /></li>
27     <li><label>起点站</label><input name="startAddress" type="text" class="dfinput" /></li>
28     <li><label>终点站</label><cite><input name="endAddress" type="text" value="" class="dfinput"/></cite></li>
29     <li><label>运行时间</label><input name="time" type="text" class="dfinput" value="" /></li>
30     <li><label>价格</label><input name="price" type="text" class="dfinput" value="" /></li>
31     <li><label>车载人数</label><input name="manned" type="text" class="dfinput" value="" /></li>
32     <li><label>余票</label><input name="ticketCount" type="text" class="dfinput" value="" /></li>
33     <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认保存"/></li>
34     </ul>
35     
36     
37     </div>
38 
39 </form>
40 </body>
41 
42 </html>
addTicket.jsp

 技术图片

 

 技术图片

 

 技术图片

 

退票

 技术图片

 

 后台界面

技术图片

 

 技术图片

 

 技术图片

技术图片
  1 <%@ page language="java" contentType="text/html; charset=utf-8"
  2     pageEncoding="utf-8"%>
  3 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  4 <!DOCTYPE html >
  5 <html>
  6 <head>
  7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8 <title>票务管理</title>
  9 <link href="css/style.css" rel="stylesheet" type="text/css" />
 10 <script type="text/javascript" src="js/jquery.js"></script>
 11 
 12 <script type="text/javascript">
 13 $(document).ready(function(){
 14   $(".click").click(function(){
 15   $(".tip").fadeIn(200);
 16   });
 17   
 18   $(".tiptop a").click(function(){
 19   $(".tip").fadeOut(200);
 20 });
 21 
 22   $(".sure").click(function(){
 23   $(".tip").fadeOut(100);
 24 });
 25 
 26   $(".cancel").click(function(){
 27   $(".tip").fadeOut(100);
 28 });
 29 
 30 });
 31 
 32 
 33     function del(tid){
 34         if(confirm("确认删除?")){
 35             window.location.href="deleteTicket?tid="+tid;
 36         }
 37     }
 38     function update(tid){
 39         window.location.href="findTicketById?opr=at&tid="+tid;
 40     }
 41 
 42 
 43 </script>
 44 
 45 
 46 </head>
 47 
 48 
 49 <body>
 50 
 51     <div class="place">
 52     <span>位置:</span>
 53     <ul class="placeul">
 54     <li><a href="#">首页</a></li>
 55     <li><a href="#">票务管理</a></li>
 56     <li><a href="#">查询所有票务信息</a></li>
 57     </ul>
 58     </div>
 59     
 60     <div class="rightinfo">
 61     <div class="formtitle"><span>票务信息</span></div>
 62     <table class="tablelist">
 63         <thead>
 64         <tr>
 65         <th><input name="" type="checkbox" value="" checked="checked"/></th>
 66         <th>车次编号<i class="sort"><img src="images/px.gif" /></i></th>
 67         <th>起点站</th>
 68         <th>终点站</th>
 69         <th>运行时间</th>
 70         <th>价格</th>
 71         <th>车载人数</th>
 72         <th>余票</th>
 73         <th>操作</th>
 74         </tr>
 75         </thead>
 76         <tbody>
 77         <c:forEach var="ticket" items="${ticketList }">
 78             <tr>
 79             <td><input name="" type="checkbox" value="" /></td>
 80             <td>${ticket.ticketNo }</td>
 81             <td>${ticket.startAddress }</td>
 82             <td>${ticket.endAddress }</td>
 83             <td>${ticket.time }</td>
 84             <td>¥${ticket.price }</td>
 85             <td>${ticket.manned } 人</td>
 86             <td>${ticket.ticketCount } 张</td>
 87             <td><a href="javascript:;" class="tablelink" onclick="update(${ticket.tid})" >编辑</a>
 88                  <a href="javascript:;" class="tablelink" onclick="del(${ticket.tid})"> 删除</a></td>
 89             </tr> 
 90         </c:forEach>
 91         </tbody>
 92     </table>
 93     
 94    
 95     <div class="pagin">
 96         <ul class="paginList">
 97         <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>
 98         <li class="paginItem"><a href="javascript:;">1</a></li>
 99         <li class="paginItem current"><a href="javascript:;">2</a></li>
100         <li class="paginItem"><a href="javascript:;">3</a></li>
101         <li class="paginItem"><a href="javascript:;">4</a></li>
102         <li class="paginItem"><a href="javascript:;">5</a></li>
103         <li class="paginItem more"><a href="javascript:;">...</a></li>
104         <li class="paginItem"><a href="javascript:;">10</a></li>
105         <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>
106         </ul>
107     </div>
108     
109     
110     <div class="tip">
111         <div class="tiptop"><span>提示信息</span><a></a></div>
112         
113       <div class="tipinfo">
114         <span><img src="images/ticon.png" /></span>
115         <div class="tipright">
116         <p>是否确认对信息的修改 ?</p>
117         <cite>如果是请点击确定按钮 ,否则请点取消。</cite>
118         </div>
119         </div>
120         
121         <div class="tipbtn">
122         <input name="" type="button"  class="sure" value="确定" />&nbsp;
123         <input name="" type="button"  class="cancel" value="取消" />
124         </div>
125     
126     </div>
127     
128     
129     
130     
131     </div>
132     
133     <script type="text/javascript">
134     $(‘.tablelist tbody tr:odd‘).addClass(‘odd‘);
135     </script>
136 
137 </body>
138 
139 </html>
adminTicket.jsp

技术图片

技术图片

三、遇到的问题:

  a.对mybatis返回数据应生成对象的时候,每一条记录都对应了一个对象,这就造成了,对象中的list属性中只有一个对象。也就是一对多变成了多条一对一。造成这种现象的原因mysql查询的结果中,返回的列没有用于区分权限的id

  b.jsp中Property ‘XXX‘ not found on type java.lang.String解决方案

四、解决办法

  a.在查询的mysql语句中,加入查询id即可。

  b.使用JSTL中的foreach标签并用EL表达式读取items时,EL表达式的后大括号与引号之间有空格,使用JSTL中的foreach标签,并且items没有使用EL表达式读取域中的内容,指令标签错误.

五、燃尽图

技术图片

 

第二周项目功能实现

标签:rap   win   jsp   w3c   ring   遇到   mes   each   spring   

原文地址:https://www.cnblogs.com/gracefully/p/13364851.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!