商城后台管理系统(⼀)
后台商品列表展⽰
1.功能截图
2.代码实现
web层
package ;
import ption;
import eption;
import ;
import tException;
import rvlet;
impo介绍绿萝 rt rvletRequest;
import rvletRespon;
import t;
import roductListService;
public class AdminProductListServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletRespon respon)
throws ServletException, IOException {
racterEncoding("UTF-8");
tentType("text/html; chart=UTF-8");
AdminProductListService rvice = new AdminProductListService();
List
try {
productList = lProduct();
} catch (SQLException e) {
tackTrace();
}
ribute("productList", productList);
uestDispatcher("/admin/product/").forward(request, respon);
}
protected void doPost(HttpServletRequest request, HttpServletRespon respon)
throws ServletException, IOException {
doGet(request, respon);
}
}
rvice层
package e;
import eption;
import ;
import roductDao;
import ry;
import t;
public class AdminProductListService {
//商品列表
public List
AdminProductDao dao = new AdminProductDao();
List
return productList;
}
//增加商品
public void addProduct(Product product) throws SQLException {
AdminProductDao dao = new AdminProductDao();
duct(product);
}
//删除商品
public void delProduct(String pid) throws SQLException {
AdminProductDao dao = new AdminProductDao();
duct(pid);
}
//商品种类
public List
AdminProductDao dao = new AdminProductDao();
List
return categoryList;
}
public Product findProductById(String pid) throws SQLException {
AdminProductDao dao = new AdminProductDao();
Product product = oductById(pid);
return product;
}
}
dao层
packag护士实习总结 e ;
import eption;
import ;
import unner;
import ndler;
import stHandler;
import r职业教育的意义 y;
import t;
import urceUtils;
public class AdminProductDao {
//商品列表
public List
QueryRunner qr = new QueryRunner(aSource());
String sql = "le世界最美的风景 ct * from product";
return (sql, new BeanListHandler
}
//增加商品
public void addProduct(Product product) throws SQLException {
QueryRunner qr = new QueryRunner(aSou代写年终总结 rce());
String sql = "inrt into product values(?,?,?,?,?,?,?,?,?,?)";
(sql, (),me(),ket_price(),p_price(),
age(),te(),_hot(),sc(),ag(),
());
煮大虾怎么煮
}
//删除商品
public void delProduct(String pid) throws SQLException {
QueryRunner qr = new QueryRunner(aSource());
String sql = "delete from product where pid = ?";
(sql, pid);
}
//查询商品种类
public List
QueryRunner qr = new QueryRunner(aSource());
String sql = "le昆明周边景点 ct * from category";
List
return categoryList;
}
public Product findProductById(String pid) throws SQLException {
QueryRunner qr = new QueryRunner(aSource());
String sql="lect * from pr敬业的名言 oduct where pid = ?";
Product product = (sql, new Bea砂锅居
nHandler
return product;
}
}
这⾥将后续⼏种功能的rvice层和dao层的代码实现都存放在⼀起
本文发布于:2023-04-25 04:14:32,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/fan/82/513333.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |