Compare commits
7 Commits
78f1155583
...
e2b6123de8
Author | SHA1 | Date |
---|---|---|
|
e2b6123de8 | |
|
032385d7a7 | |
|
2a99339bad | |
|
5bdf84c53c | |
|
cd1fd254d7 | |
|
91491824ec | |
|
01ecf1a584 |
|
@ -65,7 +65,7 @@ public class CartServlet extends HttpServlet {
|
|||
User user = (User) req.getSession().getAttribute("user");
|
||||
cartService.addCart(Integer.parseInt(id),user.getId());
|
||||
req.setAttribute("msg","加购成功");
|
||||
req.getRequestDispatcher("/computerList").forward(req,resp);
|
||||
req.getRequestDispatcher("/computer?action=list").forward(req,resp);
|
||||
}
|
||||
|
||||
private void toCart(HttpServletRequest req, HttpServletResponse resp) throws Exception {
|
||||
|
|
|
@ -10,32 +10,34 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@WebServlet(urlPatterns = {"/computerList","/deleteComputer","/addComputer","/editComputer"})
|
||||
@WebServlet(urlPatterns = {"/computer"})
|
||||
public class ComputerServlet extends HttpServlet {
|
||||
|
||||
IComputerService computerService = new ComputerServiceImpl();
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String path = req.getServletPath();
|
||||
switch (path) {
|
||||
case "/computerList":
|
||||
String action = req.getParameter("action");
|
||||
switch (action) {
|
||||
case "list":
|
||||
try {
|
||||
listServlet(req, resp);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
case "/deleteComputer":
|
||||
case "delete":
|
||||
deleteComputer(req, resp);
|
||||
break;
|
||||
case "/addComputer":
|
||||
case "add":
|
||||
addComputer(req, resp);
|
||||
break;
|
||||
case "/editComputer":
|
||||
case "edit":
|
||||
editComputer(req, resp);
|
||||
break;
|
||||
}
|
||||
|
@ -56,39 +58,54 @@ public class ComputerServlet extends HttpServlet {
|
|||
String id = req.getParameter("id");
|
||||
try {
|
||||
computerService.deleteComputer(id);
|
||||
resp.sendRedirect("/computerList");
|
||||
resp.sendRedirect("/computer?action=list");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void listServlet(HttpServletRequest req, HttpServletResponse resp) throws SQLException, ServletException, IOException {
|
||||
List<Computer> computers= computerService.listComputer();
|
||||
req.setAttribute("computers", computers);
|
||||
int page = 1;
|
||||
int pageSize = 5; // 每页显示的条数
|
||||
|
||||
// 获取页码参数
|
||||
String pageParam = req.getParameter("page");
|
||||
if (pageParam != null) {
|
||||
page = Integer.parseInt(pageParam);
|
||||
}
|
||||
|
||||
// 获取分页数据
|
||||
Map<String, Object> data = computerService.listComputersWithPagination(page, pageSize);
|
||||
|
||||
req.setAttribute("computers", data.get("computers"));
|
||||
req.setAttribute("totalPages", data.get("totalPages"));
|
||||
req.setAttribute("currentPage", data.get("currentPage"));
|
||||
|
||||
req.getRequestDispatcher("computerList.jsp").forward(req, resp);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String path = req.getServletPath();
|
||||
switch (path) {
|
||||
case "/addComputer":
|
||||
String action = req.getParameter("action");
|
||||
switch (action) {
|
||||
case "add":
|
||||
savaComputer(req, resp);
|
||||
break;
|
||||
case "/editComputer":
|
||||
UpdatComputer(req, resp);
|
||||
case "edit":
|
||||
UpdateComputer(req, resp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatComputer(HttpServletRequest req, HttpServletResponse resp) {
|
||||
private void UpdateComputer(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException {
|
||||
String id = req.getParameter("id");
|
||||
String name = req.getParameter("name");
|
||||
String price = req.getParameter("price");
|
||||
String stock = req.getParameter("stock");
|
||||
computerService.updateComputer(id,name,Double.parseDouble(price),Integer.parseInt(stock));
|
||||
try {
|
||||
resp.sendRedirect("/computerList");
|
||||
resp.sendRedirect("/computer?action=list");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -100,7 +117,7 @@ public class ComputerServlet extends HttpServlet {
|
|||
String stock = req.getParameter("stock");
|
||||
computerService.addComputer(name,Double.parseDouble(price),Integer.parseInt(stock));
|
||||
try {
|
||||
resp.sendRedirect("/computerList");
|
||||
resp.sendRedirect("/computer?action=list");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -26,12 +26,22 @@ public class OrdersServlet extends HttpServlet {
|
|||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String action = req.getParameter("action");
|
||||
switch (action) {
|
||||
case "waiting":
|
||||
ordersService.waiting(req, resp);
|
||||
break;
|
||||
case "sent":
|
||||
ordersService.sent(req, resp);
|
||||
break;
|
||||
case "all":
|
||||
ordersService.allOrder(req, resp);
|
||||
break;
|
||||
|
||||
case "my":
|
||||
ordersService.myOrder(req, resp);
|
||||
break;
|
||||
case "deliver":
|
||||
ordersService.deliver(req, resp);
|
||||
break;
|
||||
case "add":
|
||||
try {
|
||||
ordersService.checkOrder(req, resp);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class CartDao {
|
|||
// 移除购物车
|
||||
public int deleteCart(Integer user_id, Integer product_id) throws Exception {
|
||||
String sql = "delete from cart where user_id=? and product_id=?";
|
||||
return queryRunner.update(sql, user_id, product_id);
|
||||
return queryRunner.update(sql, product_id, user_id);
|
||||
}
|
||||
// 某用户的购物车
|
||||
public List<Computer> getCart(Integer user_id) throws Exception {
|
||||
|
|
|
@ -41,11 +41,21 @@ public class ComputerDao {
|
|||
}
|
||||
}
|
||||
|
||||
public List<Computer> getAllComputer() throws SQLException {
|
||||
String sql = "select * from computer";
|
||||
return queryRunner.query(sql,new BeanListHandler<>(Computer.class));
|
||||
public List<Computer> getComputersByPage(int page, int pageSize) throws SQLException {
|
||||
int offset = (page - 1) * pageSize;
|
||||
String sql = "SELECT * FROM computer LIMIT ? OFFSET ?";
|
||||
return queryRunner.query(sql, new BeanListHandler<>(Computer.class), pageSize, offset);
|
||||
}
|
||||
|
||||
public int getComputerCount() throws SQLException {
|
||||
String sql = "SELECT COUNT(*) FROM computer";
|
||||
return queryRunner.query(sql, rs -> {
|
||||
rs.next();
|
||||
return rs.getInt(1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Computer getComputerById(int i) {
|
||||
String sql = "select * from computer where id=?";
|
||||
|
|
|
@ -13,7 +13,7 @@ public class OrdersDao {
|
|||
|
||||
|
||||
public List<Orders> getAllOrders() {
|
||||
String sql = "select id,user_id userId,order_date orderDate,total_price totalPrice,address ,remark from orders o ";
|
||||
String sql = "select id,user_id userId,order_date orderDate,total_price totalPrice,address ,remark,status from orders o ";
|
||||
try {
|
||||
return queryRunner.query(sql, new BeanListHandler<>(Orders.class));
|
||||
} catch (Exception e) {
|
||||
|
@ -29,9 +29,9 @@ public class OrdersDao {
|
|||
}
|
||||
|
||||
public int addOrder(int userId,double price, String address, String remark) {
|
||||
String sql="insert into orders(user_id,order_date,total_price,address,remark) values(?,?,?,?,?)";
|
||||
String sql="insert into orders(user_id,order_date,total_price,address,remark,status) values(?,?,?,?,?,?)";
|
||||
try {
|
||||
return queryRunner.update(sql,userId, LocalDateTime.now(),price,address,remark);
|
||||
return queryRunner.update(sql,userId, LocalDateTime.now(),price,address,remark,"待发货");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class OrdersDao {
|
|||
}
|
||||
|
||||
public List<Orders> getMyOrders(int userId) {
|
||||
String sql = "select id,user_id userId,order_date orderDate,total_price totalPrice,address ,remark from orders o where user_id =?";
|
||||
String sql = "select id,user_id userId,order_date orderDate,total_price totalPrice,address ,remark,status from orders o where user_id =?";
|
||||
try {
|
||||
return queryRunner.query(sql, new BeanListHandler<>(Orders.class),userId);
|
||||
} catch (Exception e) {
|
||||
|
@ -47,4 +47,33 @@ public class OrdersDao {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void deliver(String orderId) {
|
||||
String sql = "update orders set status = ? where id = ?";
|
||||
try {
|
||||
queryRunner.update(sql,"已发货",orderId);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Orders> getOrdersOfWaiting() {
|
||||
String sql = "select id,user_id userId,order_date orderDate,total_price totalPrice,address ,remark,status from orders o where status = '待发货'";
|
||||
try {
|
||||
return queryRunner.query(sql, new BeanListHandler<>(Orders.class));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Orders> getOrdersOfSent() {
|
||||
String sql = "select id,user_id userId,order_date orderDate,total_price totalPrice,address ,remark,status from orders o where status = '已发货'";
|
||||
try {
|
||||
return queryRunner.query(sql, new BeanListHandler<>(Orders.class));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class UserDao {
|
|||
|
||||
public static void main(String[] args) throws Exception {
|
||||
UserDao userDao = new UserDao();
|
||||
System.out.println(userDao.getUserById(1).getUsername());
|
||||
System.out.println(userDao.getAllUser());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public class LoginFilter implements Filter {
|
|||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
HttpSession session = request.getSession(false);
|
||||
String requestURI = request.getRequestURI();
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
try {
|
||||
if (requestURI.contains("login.jsp") || requestURI.contains("login") || requestURI.contains("/")) {
|
||||
filterChain.doFilter(request, response);
|
||||
|
|
|
@ -7,4 +7,27 @@ public class Cart {
|
|||
|
||||
private Integer productId;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,16 +15,14 @@ public class Orders {
|
|||
|
||||
private String remark;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Orders{" +
|
||||
"id=" + id +
|
||||
", userId=" + userId +
|
||||
", orderDate=" + orderDate +
|
||||
", totalPrice=" + totalPrice +
|
||||
", address='" + address + '\'' +
|
||||
", remark='" + remark + '\'' +
|
||||
'}';
|
||||
private String status;
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import example.model.Computer;
|
|||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IComputerService {
|
||||
|
||||
|
@ -16,4 +17,6 @@ public interface IComputerService {
|
|||
Computer getComputer(String id);
|
||||
|
||||
void updateComputer(String id, String name, double v, int i);
|
||||
|
||||
Map<String, Object> listComputersWithPagination(int page, int pageSize) throws SQLException;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,10 @@ package example.service;
|
|||
|
||||
import example.model.Orders;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface IOrdersService {
|
||||
|
@ -15,4 +17,10 @@ public interface IOrdersService {
|
|||
int addOrder(int userId,double price, String address, String remark);
|
||||
|
||||
void myOrder(HttpServletRequest req, HttpServletResponse resp);
|
||||
|
||||
void deliver(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
|
||||
|
||||
void waiting(HttpServletRequest req, HttpServletResponse resp);
|
||||
|
||||
void sent(HttpServletRequest req, HttpServletResponse resp);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,10 @@ import example.model.Computer;
|
|||
import example.service.IComputerService;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ComputerServiceImpl implements IComputerService {
|
||||
|
||||
|
@ -19,9 +22,10 @@ public class ComputerServiceImpl implements IComputerService {
|
|||
|
||||
@Override
|
||||
public List<Computer> listComputer() throws SQLException {
|
||||
return computerDao.getAllComputer();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteComputer(String id) {
|
||||
computerDao.deleteComputer(Integer.parseInt(id));
|
||||
|
@ -36,4 +40,20 @@ public class ComputerServiceImpl implements IComputerService {
|
|||
public void updateComputer(String id, String name, double v, int i) {
|
||||
computerDao.updateComputer(name, v, i, Integer.parseInt(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> listComputersWithPagination(int page, int pageSize) throws SQLException {
|
||||
List<Computer> computers = computerDao.getComputersByPage(page, pageSize);
|
||||
int totalCount = computerDao.getComputerCount();
|
||||
int totalPages = (int) Math.ceil((double) totalCount / pageSize);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("computers", computers);
|
||||
result.put("totalPages", totalPages);
|
||||
result.put("currentPage", page);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,10 @@ import example.model.Orders;
|
|||
import example.model.User;
|
||||
import example.service.IOrdersService;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class OrdersServiceImpl implements IOrdersService {
|
||||
|
@ -63,4 +65,33 @@ public class OrdersServiceImpl implements IOrdersService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deliver(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String orderId = req.getParameter("id");
|
||||
ordersDao.deliver(orderId);
|
||||
req.getRequestDispatcher("/orders?action=all").forward(req,resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void waiting(HttpServletRequest req, HttpServletResponse resp) {
|
||||
List<Orders> allOrders = ordersDao.getOrdersOfWaiting();
|
||||
req.setAttribute("Orders",allOrders);
|
||||
try {
|
||||
req.getRequestDispatcher("orders.jsp").forward(req,resp);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sent(HttpServletRequest req, HttpServletResponse resp) {
|
||||
List<Orders> allOrders = ordersDao.getOrdersOfSent();
|
||||
req.setAttribute("Orders",allOrders);
|
||||
try {
|
||||
req.getRequestDispatcher("orders.jsp").forward(req,resp);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,22 +3,10 @@ package example.utils;
|
|||
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
||||
|
||||
public class DBUtils {
|
||||
private static ComboPooledDataSource dataSource;
|
||||
|
||||
static {
|
||||
try {
|
||||
dataSource = new ComboPooledDataSource();
|
||||
dataSource.setDriverClass("com.mysql.cj.jdbc.Driver");
|
||||
dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/work?useSSL=false&serverTimezone=UTC");
|
||||
dataSource.setUser("root");
|
||||
dataSource.setPassword("root");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// 使用默认配置名 "default-config" 从c3p0-config.xml文件中获取数据源配置
|
||||
private static ComboPooledDataSource dataSource = new ComboPooledDataSource("default-config");
|
||||
|
||||
public static ComboPooledDataSource getDataSource() {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<c3p0-config>
|
||||
<default-config>
|
||||
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/work?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false</property>
|
||||
<property name="user">root</property>
|
||||
<property name="password">root</property>
|
||||
</default-config>
|
||||
</c3p0-config>
|
|
@ -9,7 +9,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>电脑产品发布</h1>
|
||||
<form action="/addComputer" method="post">
|
||||
<form action="/computer?action=add" method="post">
|
||||
<label for="name">名称: </label><br>
|
||||
<input type="text" id="name" name="name"><br><br>
|
||||
<label for="price">价格: </label><br>
|
||||
|
@ -19,6 +19,6 @@
|
|||
<input type="submit" value="确定">
|
||||
</form>
|
||||
<br>
|
||||
<a href="/computerList">返回电脑列表</a>
|
||||
<a href="/computer?action=list">返回电脑列表</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
<td>${computer.stock}</td>
|
||||
<td>
|
||||
<c:if test="${sessionScope.user.role == 'admin'}">
|
||||
<a href="/editComputer?id=${computer.id}">编辑</a> |
|
||||
<a href="/deleteComputer?id=${computer.id}">删除</a>
|
||||
<a href="/computer?action=edit&id=${computer.id}">编辑</a> |
|
||||
<a href="/computer?action=delete&id=${computer.id}">删除</a>
|
||||
</c:if>
|
||||
|
||||
|
||||
|
@ -44,6 +44,31 @@
|
|||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<!-- 首页链接 -->
|
||||
<a href="/computer?action=list&page=1">首页</a>
|
||||
|
||||
<!-- 上一页链接 -->
|
||||
<c:if test="${currentPage > 1}">
|
||||
<a href="/computer?action=list&page=${currentPage - 1}">上一页</a>
|
||||
</c:if>
|
||||
|
||||
<!-- 分页页码 -->
|
||||
<c:forEach var="i" begin="1" end="${totalPages}">
|
||||
<a href="/computer?action=list&page=${i}"
|
||||
style="margin: 0 5px; ${i == currentPage ? 'font-weight:bold;' : ''}">
|
||||
${i}
|
||||
</a>
|
||||
</c:forEach>
|
||||
|
||||
<!-- 下一页链接 -->
|
||||
<c:if test="${currentPage < totalPages}">
|
||||
<a href="/computer?action=list&page=${currentPage + 1}">下一页</a>
|
||||
</c:if>
|
||||
|
||||
<!-- 尾页链接 -->
|
||||
<a href="/computer?action=list&page=${totalPages}">尾页</a>
|
||||
</div>
|
||||
<hr>
|
||||
<p style="color: red;">${requestScope.msg}</p>
|
||||
|
||||
|
@ -52,7 +77,7 @@
|
|||
<a href="/cart?action=list">我的购物车</a>
|
||||
</c:if>
|
||||
<c:if test="${sessionScope.user.role == 'admin'}">
|
||||
<a href="/addComputer">发布电脑产品</a>
|
||||
<a href="/computer?action=add">发布电脑产品</a>
|
||||
</c:if>
|
||||
<br>
|
||||
<a href="/">主页</a>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>更新电脑信息</h1>
|
||||
<form action="/editComputer" method="post">
|
||||
<form action="/computer?action=edit" method="post">
|
||||
<input type="hidden" name="id" value="${computer.id}">
|
||||
<label for="name">名称: </label><br>
|
||||
<input type="text" id="name" name="name" value="${computer.name}"><br><br>
|
||||
|
@ -21,6 +21,6 @@
|
|||
<input type="submit" value="提交修改">
|
||||
</form>
|
||||
<br>
|
||||
<a href="/computerList">返回电脑列表</a>
|
||||
<a href="/computer?action=list">返回电脑列表</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<h2>电脑商城-首页</h2>
|
||||
<p>你好!${sessionScope.user.username}</p>
|
||||
<c:if test="${sessionScope.user!= null}">
|
||||
<a href="/computerList">电脑选购</a>
|
||||
<a href="/computer?action=list">电脑选购</a>
|
||||
<c:if test="${sessionScope.user.role == 'user'}">
|
||||
<a href="/cart?action=list">我的购物车</a>
|
||||
<a href="/orders?action=my">我的订单</a>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<a href="/user?action=list">用户列表</a>
|
||||
<a href="/orders?action=all">所有订单</a>
|
||||
</c:if>
|
||||
<a href="/logout">注销登录</a>
|
||||
<a href="/logout">退出</a>
|
||||
|
||||
</c:if>
|
||||
<c:if test="${sessionScope.user == null}">
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
<th>总金额</th>
|
||||
<th>地址</th>
|
||||
<th>商品信息</th>
|
||||
<th>状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -34,6 +35,7 @@
|
|||
<td>${order.totalPrice}</td>
|
||||
<td>${order.address}</td>
|
||||
<td>${order.remark}</td>
|
||||
<td>${order.status}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
|
|
|
@ -2,14 +2,21 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<script src="https://www.liyansheng.top/cdn/watermark.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>订单列表</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>订单列表</h1>
|
||||
<a href="/orders?action=all">全部</a> |
|
||||
<a href="/orders?action=waiting">待发货</a> |
|
||||
<a href="/orders?action=sent">已发货</a>
|
||||
<br>
|
||||
<br>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -19,6 +26,7 @@
|
|||
<th>总金额</th>
|
||||
<th>地址</th>
|
||||
<th>商品信息</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -31,15 +39,20 @@
|
|||
<td>${order.totalPrice}</td>
|
||||
<td>${order.address}</td>
|
||||
<td>${order.remark}</td>
|
||||
<td>${order.status}</td>
|
||||
<td>
|
||||
<a href="/orders?action=delete&id=${order.id}">删除</a>
|
||||
<c:if test="${order.status!= '已发货'}">
|
||||
<a href="/orders?action=deliver&id=${order.id}">
|
||||
点击发货 </a>
|
||||
</c:if>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
<br />
|
||||
<br>
|
||||
<a href="/">主页</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
Reference in New Issue