package com.zgw.web;
import java.io.File;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.zgw.dto.ProductPage;
import com.zgw.pojo.Cart;
import com.zgw.pojo.Product;
import com.zgw.service.ProductService;
public class ProductAction extends ActionSupport{
public String getProductByType(){
HttpServletRequest req=ServletActionContext.getRequest();
ProductService ps=new ProductService();
String pType=req.getParameter("pType");
String con=req.getParameter("con");
int pageNo1=1;
String pageNo=req.getParameter("pageNo");
if(pageNo!=null){
pageNo1=Integer.parseInt(pageNo);
}
if(pageNo1<2){
pageNo1=1;
}
ProductPage proPage=new ProductPage();
int count=ps.getCont(proPage);
req.setAttribute("count", count);
if(pageNo1>count){
pageNo1=count;
}
req.setAttribute("pageNo1", pageNo1);
req.setAttribute("con", con);
proPage.setCon(con);
proPage.setPageNo((pageNo1-1)*6);
proPage.setpType(pType);
List<Product> list=ps.getProductByType(proPage);
req.setAttribute("list", list);
return SUCCESS;
}
private int pid;
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getProductById(){
HttpServletRequest req=ServletActionContext.getRequest();
ProductService ps=new ProductService();
Product pro=ps.getProductById(pid);
req.setAttribute("product", pro);
return SUCCESS;
}
public String insertCart(){
ProductService ps=new ProductService();
Cart cart =new Cart();
cart.setcPid(pid);
cart.setcUid(1);
boolean bool=ps.insertCart(cart);
if(bool){
return SUCCESS;
}else{
return "fail";
}
}
public String getCart(){
HttpServletRequest req=ServletActionContext.getRequest();
ProductService ps=new ProductService();
List<Cart> listCart=ps.getCart();
req.setAttribute("listCart", listCart);
return SUCCESS;
}
private int cid;
public int getCid() {
return cid;
}
public void setCid(int cid) {
this.cid = cid;
}
public void deleteCartPro(){
ProductService ps=new ProductService();
ps.deleteCartPro(cid);
}
// 显示商品
private String pname;
public String getPname() {
return pname;
}
public void setPname(String pname) {
this.pname = pname;
}
public String getFood(){
ProductService ps=new ProductService();
List<Product> list=ps.getFood(pname);
HttpServletRequest req=ServletActionContext.getRequest();
req.setAttribute("list", list);
return SUCCESS;
}
// 删除菜品
public String deleteFood(){
ProductService ps=new ProductService();
boolean flag=ps.deleteFood(pid);
if(flag){
return SUCCESS;
}else{
return "input";
}
}
// 查询单个商品
public String getFoodById(){
ProductService ps=new ProductService();
Product product=ps.getProductById(pid);
HttpServletRequest req=ServletActionContext.getRequest();
req.setAttribute("product",product);
return SUCCESS;
}
// 修改菜品
private String psynopsis;
private double price;
private String ptype;
private File img;
private String imgFileName;
private String imgContentType;
public String getPsynopsis() {
return psynopsis;
}
public void setPsynopsis(String psynopsis) {
this.psynopsis = psynopsis;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getPtype() {
return ptype;
}
public void setPtype(String ptype) {
this.ptype = ptype;
}
public File getImg() {
return img;
}
public void setImg(File img) {
this.img = img;
}
public String getImgFileName() {
return imgFileName;
}
public void setImgFileName(String imgFileName) {
this.imgFileName = imgFileName;
}
public String getImgContentType() {
return imgContentType;
}
public void setImgContentType(String imgContentType) {
this.imgContentType = imgContentType;
}
public String updateFood()throws Exception{
HttpServletRequest req=ServletActionContext.getRequest();
String root = ServletActionContext.getRequest().getRealPath("/image");
FileUtils.copyFile(img, new File(root+"/"+imgFileName));
Product p=new Product();
p.setpId(pid);
p.setImg("image/"+imgFileName);
p.setpName(pname);
p.setPrice(price);
p.setpSynopsis(psynopsis);
p.setpType(ptype);
ProductService ps=new ProductService();
ps.UpdateFood(p);
return SUCCESS;
}
public String saveFood()throws Exception{
HttpServletRequest req=ServletActionContext.getRequest();
String root = ServletActionContext.getRequest().getRealPath("/image");
FileUtils.copyFile(img, new File(root+"/"+imgFileName));
Product p=new Product();
p.setpId(pid);
p.setImg("image/"+imgFileName);
p.setpName(pname);
p.setPrice(price);
p.setpSynopsis(psynopsis);
p.setpType(ptype);
ProductService ps=new ProductService();
ps.saveFood(p);
return SUCCESS;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于javaweb的点餐系统 jsp+struts2+mabatis+mysql
共192个文件
gif:40个
class:21个
java:21个
2星 需积分: 34 66 下载量 133 浏览量
2017-11-20
11:21:18
上传
评论 3
收藏 9.45MB ZIP 举报
温馨提示
基于javaweb的点餐系统 jsp+struts2+mabatis+mysql,此系统分为用户和管理员两大模块
资源推荐
资源详情
资源评论
收起资源包目录
基于javaweb的点餐系统 jsp+struts2+mabatis+mysql (192个子文件)
ProductAction.class 6KB
ProductService.class 3KB
EncodingFilter.class 3KB
UserAction.class 3KB
UserService.class 2KB
AdminAction.class 2KB
Product.class 1KB
Order.class 1KB
OrderAction.class 1KB
Users.class 1KB
OrderService.class 1KB
Cart.class 1KB
AdminInterceptor.class 1KB
DBHleper.class 1KB
ProductPage.class 919B
Admin.class 909B
ProductMapper.class 877B
AdminService.class 835B
UserMapper.class 504B
OrderMapper.class 241B
AdminMapper.class 181B
.classpath 2KB
org.eclipse.wst.common.component 558B
org.eclipse.wst.jsdt.ui.superType.container 49B
common_style_blue.css 6KB
common_style_blue.css 6KB
index.css 4KB
index_1.css 2KB
index_1.css 2KB
normalize.css 2KB
dis_message.css 600B
middle_bg.gif 370KB
menubg.gif 163KB
flower.gif 64KB
flower.gif 64KB
dish_circle.gif 40KB
index_menu.gif 24KB
bg2.gif 8KB
look.gif 6KB
middle_left.gif 5KB
call2.gif 4KB
middle_left2.gif 4KB
table.gif 4KB
select.gif 3KB
btndish.gif 2KB
right_input.gif 2KB
menu_btn_bg.gif 2KB
logout.gif 2KB
help2.gif 2KB
btn2.gif 2KB
version.gif 1KB
func20001.gif 570B
info.gif 539B
user.gif 339B
Header_refresh.gif 332B
title_bg_end.gif 331B
title_bg_end.gif 331B
Header_back.gif 310B
Header_forward.gif 308B
top_head1_bg.gif 284B
circle.gif 246B
title_bg_head.gif 201B
title_bg_head.gif 201B
inputPageHeadBg.gif 161B
inputPageHeadBg.gif 161B
title_bg.gif 154B
title_bg.gif 154B
title_arrow.gif 136B
menu_arrow_single.gif 86B
top_head2_bg.gif 68B
item_point.gif 59B
mybatis-3.4.1.jar 1.51MB
freemarker-2.3.22.jar 1.24MB
mysql-connector-java-5.1.42-bin.jar 973KB
struts2-core-2.3.24.jar 812KB
log4j-core-2.2.jar 807KB
xwork-core-2.3.24.jar 661KB
javassist-3.11.0.GA.jar 600KB
commons-lang3-3.2.jar 376KB
log4j.jar 350KB
ognl-3.0.6.jar 223KB
commons-io-2.2.jar 170KB
log4j-api-2.2.jar 130KB
commons-fileupload-1.3.1.jar 67KB
asm-3.3.jar 43KB
asm-commons-3.3.jar 37KB
asm-tree-3.3.jar 21KB
ProductAction.java 5KB
ProductService.java 3KB
UserAction.java 2KB
EncodingFilter.java 2KB
UserService.java 1KB
AdminAction.java 1KB
Product.java 892B
Order.java 858B
OrderService.java 856B
ProductMapper.java 826B
OrderAction.java 793B
Users.java 768B
AdminInterceptor.java 607B
共 192 条
- 1
- 2
资源评论
- qq-12273226872018-12-06运行时报错,可能是java与数据库连接出现问题,希望改正,qq1227322687Daniel_¹⁰²⁴2019-03-29好的
Daniel_¹⁰²⁴
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- 基于JSP毕业设计-基于WEB操作系统课程教学网站的设计与实现(源代码+论文).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功