how2j.cn

下载区
文件名 文件大小
请先登录 1m
增值内容 1m
1m
步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 页面截图   
步骤 4 : ProductImage   
步骤 5 : ProductImageService   
步骤 6 : ProductImageServiceImpl   
步骤 7 : ProductImageController   
步骤 8 : listProductImage.jsp   
步骤 9 : 查询功能讲解   
步骤 10 : 增加功能讲解   
步骤 11 : 删除功能讲解   
步骤 12 : 编辑和修改   
步骤 13 : Product   
步骤 14 : ProductService   
步骤 15 : ProductServiceImpl   
步骤 16 : listProduct.jsp   
步骤 17 : 产品缩略图效果   

步骤 1 :

先运行,看到效果,再学习

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
页面截图
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
步骤 5 :

ProductImageService

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service; import java.util.List; import com.how2java.tmall.pojo.ProductImage; public interface ProductImageService { String type_single = "type_single"; String type_detail = "type_detail"; void add(ProductImage pi); void delete(int id); void update(ProductImage pi); ProductImage get(int id); List list(int pid, String type); }
package com.how2java.tmall.service;
 
import java.util.List;

import com.how2java.tmall.pojo.ProductImage;

public interface ProductImageService {

    String type_single = "type_single";
    String type_detail = "type_detail";

    void add(ProductImage pi);
    void delete(int id);
    void update(ProductImage pi);
    ProductImage get(int id);
    List list(int pid, String type);
}
步骤 6 :

ProductImageServiceImpl

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.how2java.tmall.mapper.ProductImageMapper; import com.how2java.tmall.pojo.ProductImage; import com.how2java.tmall.pojo.ProductImageExample; import com.how2java.tmall.service.ProductImageService; @Service public class ProductImageServiceImpl implements ProductImageService { @Autowired ProductImageMapper productImageMapper; @Override public void add(ProductImage pi) { productImageMapper.insert(pi); } @Override public void delete(int id) { productImageMapper.deleteByPrimaryKey(id); } @Override public void update(ProductImage pi) { productImageMapper.updateByPrimaryKeySelective(pi); } @Override public ProductImage get(int id) { return productImageMapper.selectByPrimaryKey(id); } @Override public List list(int pid, String type) { ProductImageExample example =new ProductImageExample(); example.createCriteria() .andPidEqualTo(pid) .andTypeEqualTo(type); example.setOrderByClause("id desc"); return productImageMapper.selectByExample(example); } }
步骤 7 :

ProductImageController

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.controller; import java.awt.image.BufferedImage; import java.io.File; import java.util.List; import javax.imageio.ImageIO; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import com.how2java.tmall.pojo.Product; import com.how2java.tmall.pojo.ProductImage; import com.how2java.tmall.service.ProductImageService; import com.how2java.tmall.service.ProductService; import com.how2java.tmall.util.ImageUtil; import com.how2java.tmall.util.Page; import com.how2java.tmall.util.UploadedImageFile; @Controller @RequestMapping("") public class ProductImageController { @Autowired ProductService productService; @Autowired ProductImageService productImageService; @RequestMapping("admin_productImage_add") public String add(ProductImage pi, HttpSession session, UploadedImageFile uploadedImageFile) { productImageService.add(pi); String fileName = pi.getId()+ ".jpg"; String imageFolder; String imageFolder_small=null; String imageFolder_middle=null; if(ProductImageService.type_single.equals(pi.getType())){ imageFolder= session.getServletContext().getRealPath("img/productSingle"); imageFolder_small= session.getServletContext().getRealPath("img/productSingle_small"); imageFolder_middle= session.getServletContext().getRealPath("img/productSingle_middle"); } else{ imageFolder= session.getServletContext().getRealPath("img/productDetail"); } File f = new File(imageFolder, fileName); f.getParentFile().mkdirs(); try { uploadedImageFile.getImage().transferTo(f); BufferedImage img = ImageUtil.change2jpg(f); ImageIO.write(img, "jpg", f); if(ProductImageService.type_single.equals(pi.getType())) { File f_small = new File(imageFolder_small, fileName); File f_middle = new File(imageFolder_middle, fileName); ImageUtil.resizeImage(f, 56, 56, f_small); ImageUtil.resizeImage(f, 217, 190, f_middle); } } catch (Exception e) { e.printStackTrace(); } return "redirect:admin_productImage_list?pid="+pi.getPid(); } @RequestMapping("admin_productImage_delete") public String delete(int id,HttpSession session) { ProductImage pi = productImageService.get(id); String fileName = pi.getId()+ ".jpg"; String imageFolder; String imageFolder_small=null; String imageFolder_middle=null; if(ProductImageService.type_single.equals(pi.getType())){ imageFolder= session.getServletContext().getRealPath("img/productSingle"); imageFolder_small= session.getServletContext().getRealPath("img/productSingle_small"); imageFolder_middle= session.getServletContext().getRealPath("img/productSingle_middle"); File imageFile = new File(imageFolder,fileName); File f_small = new File(imageFolder_small,fileName); File f_middle = new File(imageFolder_middle,fileName); imageFile.delete(); f_small.delete(); f_middle.delete(); } else{ imageFolder= session.getServletContext().getRealPath("img/productDetail"); File imageFile = new File(imageFolder,fileName); imageFile.delete(); } productImageService.delete(id); return "redirect:admin_productImage_list?pid="+pi.getPid(); } @RequestMapping("admin_productImage_list") public String list(int pid, Model model) { Product p =productService.get(pid); List<ProductImage> pisSingle = productImageService.list(pid, ProductImageService.type_single); List<ProductImage> pisDetail = productImageService.list(pid, ProductImageService.type_detail); model.addAttribute("p", p); model.addAttribute("pisSingle", pisSingle); model.addAttribute("pisDetail", pisDetail); return "admin/listProductImage"; } }
步骤 8 :

listProductImage.jsp

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@include file="../include/admin/adminHeader.jsp"%> <%@include file="../include/admin/adminNavigator.jsp"%> <script> $(function(){ $(".addFormSingle").submit(function(){ if(checkEmpty("filepathSingle","图片文件")){ $("#filepathSingle").value(""); return true; } return false; }); $(".addFormDetail").submit(function(){ if(checkEmpty("filepathDetail","图片文件")) return true; return false; }); }); </script> <title>产品图片管理</title> <div class="workingArea"> <ol class="breadcrumb"> <li><a href="admin_category_list">所有分类</a></li> <li><a href="admin_product_list?cid=${p.category.id}">${p.category.name}</a></li> <li class="active">${p.name}</li> <li class="active">产品图片管理</li> </ol> <table class="addPictureTable" align="center"> <tr> <td class="addPictureTableTD"> <div> <div class="panel panel-warning addPictureDiv"> <div class="panel-heading">新增产品<b class="text-primary"> 单个 </b>图片</div> <div class="panel-body"> <form method="post" class="addFormSingle" action="admin_productImage_add" enctype="multipart/form-data"> <table class="addTable"> <tr> <td>请选择本地图片 尺寸400X400 为佳</td> </tr> <tr> <td> <input id="filepathSingle" type="file" name="image" /> </td> </tr> <tr class="submitTR"> <td align="center"> <input type="hidden" name="type" value="type_single" /> <input type="hidden" name="pid" value="${p.id}" /> <button type="submit" class="btn btn-success">提 交</button> </td> </tr> </table> </form> </div> </div> <table class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr class="success"> <th>ID</th> <th>产品单个图片缩略图</th> <th>删除</th> </tr> </thead> <tbody> <c:forEach items="${pisSingle}" var="pi"> <tr> <td>${pi.id}</td> <td> <a title="点击查看原图" href="img/productSingle/${pi.id}.jpg"><img height="50px" src="img/productSingle/${pi.id}.jpg"></a> </td> <td><a deleteLink="true" href="admin_productImage_delete?id=${pi.id}"><span class=" glyphicon glyphicon-trash"></span></a></td> </tr> </c:forEach> </tbody> </table> </div> </td> <td class="addPictureTableTD"> <div> <div class="panel panel-warning addPictureDiv"> <div class="panel-heading">新增产品<b class="text-primary"> 详情 </b>图片</div> <div class="panel-body"> <form method="post" class="addFormDetail" action="admin_productImage_add" enctype="multipart/form-data"> <table class="addTable"> <tr> <td>请选择本地图片 宽度790 为佳</td> </tr> <tr> <td> <input id="filepathDetail" type="file" name="image" /> </td> </tr> <tr class="submitTR"> <td align="center"> <input type="hidden" name="type" value="type_detail" /> <input type="hidden" name="pid" value="${p.id}" /> <button type="submit" class="btn btn-success">提 交</button> </td> </tr> </table> </form> </div> </div> <table class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr class="success"> <th>ID</th> <th>产品详情图片缩略图</th> <th>删除</th> </tr> </thead> <tbody> <c:forEach items="${pisDetail}" var="pi"> <tr> <td>${pi.id}</td> <td> <a title="点击查看原图" href="img/productDetail/${pi.id}.jpg"><img height="50px" src="img/productDetail/${pi.id}.jpg"></a> </td> <td><a deleteLink="true" href="admin_productImage_delete?id=${pi.id}"><span class=" glyphicon glyphicon-trash"></span></a></td> </tr> </c:forEach> </tbody> </table> </div> </td> </tr> </table> </div> <%@include file="../include/admin/adminFooter.jsp"%>
步骤 9 :

查询功能讲解

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
查询功能讲解
@RequestMapping("admin_productImage_list") public String list(int pid, Model model) { Product p =productService.get(pid); List<ProductImage> pisSingle = productImageService.list(pid, ProductImageService.type_single); List<ProductImage> pisDetail = productImageService.list(pid, ProductImageService.type_detail); model.addAttribute("p", p); model.addAttribute("pisSingle", pisSingle); model.addAttribute("pisDetail", pisDetail); return "admin/listProductImage"; }
<c:forEach items="${pisSingle}" var="pi"> <tr> <td>${pi.id}</td> <td> <a title="点击查看原图" href="img/productSingle/${pi.id}.jpg"><img height="50px" src="img/productSingle/${pi.id}.jpg"></a> </td> <td><a deleteLink="true" href="admin_productImage_delete?id=${pi.id}"><span class=" glyphicon glyphicon-trash"></span></a></td> </tr> </c:forEach>
<c:forEach items="${pisDetail}" var="pi"> <tr> <td>${pi.id}</td> <td> <a title="点击查看原图" href="img/productDetail/${pi.id}.jpg"><img height="50px" src="img/productDetail/${pi.id}.jpg"></a> </td> <td><a deleteLink="true" href="admin_productImage_delete?id=${pi.id}"><span class=" glyphicon glyphicon-trash"></span></a></td> </tr> </c:forEach>
步骤 10 :

增加功能讲解

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增加功能讲解
<form method="post" class="addFormSingle" action="admin_productImage_add" enctype="multipart/form-data"> <table class="addTable"> <tr> <td>请选择本地图片 尺寸400X400 为佳</td> </tr> <tr> <td> <input id="imageSingle" type="file" name="image" /> </td> </tr> <tr class="submitTR"> <td align="center"> <input type="hidden" name="type" value="type_single" /> <input type="hidden" name="pid" value="${p.id}" /> <button type="submit" class="btn btn-success">提 交</button> </td> </tr> </table> </form>
@RequestMapping("admin_productImage_add") public String add(ProductImage pi, HttpSession session, UploadedImageFile uploadedImageFile) { productImageService.add(pi); String fileName = pi.getId()+ ".jpg"; String imageFolder; String imageFolder_small=null; String imageFolder_middle=null; if(ProductImageService.type_single.equals(pi.getType())){ imageFolder= session.getServletContext().getRealPath("img/productSingle"); imageFolder_small= session.getServletContext().getRealPath("img/productSingle_small"); imageFolder_middle= session.getServletContext().getRealPath("img/productSingle_middle"); } else{ imageFolder= session.getServletContext().getRealPath("img/productDetail"); } File f = new File(imageFolder, fileName); f.getParentFile().mkdirs(); try { uploadedImageFile.getImage().transferTo(f); BufferedImage img = ImageUtil.change2jpg(f); ImageIO.write(img, "jpg", f); if(ProductImageService.type_single.equals(pi.getType())) { File f_small = new File(imageFolder_small, fileName); File f_middle = new File(imageFolder_middle, fileName); ImageUtil.resizeImage(f, 56, 56, f_small); ImageUtil.resizeImage(f, 217, 190, f_middle); } } catch (Exception e) { e.printStackTrace(); } return "redirect:admin_productImage_list?pid="+pi.getPid(); }
步骤 11 :

删除功能讲解

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
删除功能讲解
@RequestMapping("admin_productImage_delete") public String delete(int id,HttpSession session) { ProductImage pi = productImageService.get(id); String fileName = pi.getId()+ ".jpg"; String imageFolder; String imageFolder_small=null; String imageFolder_middle=null; if(ProductImageService.type_single.equals(pi.getType())){ imageFolder= session.getServletContext().getRealPath("img/productSingle"); imageFolder_small= session.getServletContext().getRealPath("img/productSingle_small"); imageFolder_middle= session.getServletContext().getRealPath("img/productSingle_middle"); File imageFile = new File(imageFolder,fileName); File f_small = new File(imageFolder_small,fileName); File f_middle = new File(imageFolder_middle,fileName); imageFile.delete(); f_small.delete(); f_middle.delete(); } else{ imageFolder= session.getServletContext().getRealPath("img/productDetail"); File imageFile = new File(imageFolder,fileName); imageFile.delete(); } productImageService.delete(id); return "redirect:admin_productImage_list?pid="+pi.getPid(); }
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
Product
package com.how2java.tmall.pojo; import java.util.Date; import java.util.List; public class Product { private Integer id; private String name; private String subTitle; private Float originalPrice; private Float promotePrice; private Integer stock; private Integer cid; private Date createDate; /*非数据库字段*/ private Category category; private ProductImage firstProductImage; public ProductImage getFirstProductImage() { return firstProductImage; } public void setFirstProductImage(ProductImage firstProductImage) { this.firstProductImage = firstProductImage; } public Category getCategory() { return category; } public void setCategory(Category category) { this.category = category; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name == null ? null : name.trim(); } public String getSubTitle() { return subTitle; } public void setSubTitle(String subTitle) { this.subTitle = subTitle == null ? null : subTitle.trim(); } public Float getOriginalPrice() { return originalPrice; } public void setOriginalPrice(Float originalPrice) { this.originalPrice = originalPrice; } public Float getPromotePrice() { return promotePrice; } public void setPromotePrice(Float promotePrice) { this.promotePrice = promotePrice; } public Integer getStock() { return stock; } public void setStock(Integer stock) { this.stock = stock; } public Integer getCid() { return cid; } public void setCid(Integer cid) { this.cid = cid; } public Date getCreateDate() { return createDate; } public void setCreateDate(Date createDate) { this.createDate = createDate; } }
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service; import java.util.List; import com.how2java.tmall.pojo.Category; import com.how2java.tmall.pojo.Product; public interface ProductService { void add(Product p); void delete(int id); void update(Product p); Product get(int id); List list(int cid); void setFirstProductImage(Product p); }
package com.how2java.tmall.service;
 
import java.util.List;

import com.how2java.tmall.pojo.Category;
import com.how2java.tmall.pojo.Product;

public interface ProductService {
    void add(Product p);
    void delete(int id);
    void update(Product p);
    Product get(int id);
    List list(int cid);
    void setFirstProductImage(Product p);

}
步骤 15 :

ProductServiceImpl

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service.impl; import com.how2java.tmall.mapper.ProductMapper; import com.how2java.tmall.pojo.Category; import com.how2java.tmall.pojo.Product; import com.how2java.tmall.pojo.ProductExample; import com.how2java.tmall.pojo.ProductImage; import com.how2java.tmall.service.CategoryService; import com.how2java.tmall.service.ProductImageService; import com.how2java.tmall.service.ProductService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class ProductServiceImpl implements ProductService { @Autowired ProductMapper productMapper; @Autowired CategoryService categoryService; @Autowired ProductImageService productImageService; @Override public void add(Product p) { productMapper.insert(p); } @Override public void delete(int id) { productMapper.deleteByPrimaryKey(id); } @Override public void update(Product p) { productMapper.updateByPrimaryKeySelective(p); } @Override public Product get(int id) { Product p = productMapper.selectByPrimaryKey(id); setFirstProductImage(p); setCategory(p); return p; } public void setCategory(List<Product> ps){ for (Product p : ps) setCategory(p); } public void setCategory(Product p){ int cid = p.getCid(); Category c = categoryService.get(cid); p.setCategory(c); } @Override public List list(int cid) { ProductExample example = new ProductExample(); example.createCriteria().andCidEqualTo(cid); example.setOrderByClause("id desc"); List result = productMapper.selectByExample(example); setCategory(result); setFirstProductImage(result); return result; } @Override public void setFirstProductImage(Product p) { List<ProductImage> pis = productImageService.list(p.getId(), ProductImageService.type_single); if (!pis.isEmpty()) { ProductImage pi = pis.get(0); p.setFirstProductImage(pi); } } public void setFirstProductImage(List<Product> ps) { for (Product p : ps) { setFirstProductImage(p); } } }
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@include file="../include/admin/adminHeader.jsp"%> <%@include file="../include/admin/adminNavigator.jsp"%> <script> $(function() { $("#addForm").submit(function() { if (!checkEmpty("name", "产品名称")) return false; // if (!checkEmpty("subTitle", "小标题")) // return false; if (!checkNumber("originalPrice", "原价格")) return false; if (!checkNumber("promotePrice", "优惠价格")) return false; if (!checkInt("stock", "库存")) return false; return true; }); }); </script> <title>产品管理</title> <div class="workingArea"> <ol class="breadcrumb"> <li><a href="admin_category_list">所有分类</a></li> <li><a href="admin_product_list?cid=${c.id}">${c.name}</a></li> <li class="active">产品管理</li> </ol> <div class="listDataTableDiv"> <table class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr class="success"> <th>ID</th> <th>图片</th> <th>产品名称</th> <th>产品小标题</th> <th width="53px">原价格</th> <th width="80px">优惠价格</th> <th width="80px">库存数量</th> <th width="80px">图片管理</th> <th width="80px">设置属性</th> <th width="42px">编辑</th> <th width="42px">删除</th> </tr> </thead> <tbody> <c:forEach items="${ps}" var="p"> <tr> <td>${p.id}</td> <td> <c:if test="${!empty p.firstProductImage}"> <img width="40px" src="img/productSingle/${p.firstProductImage.id}.jpg"> </c:if> </td> <td>${p.name}</td> <td>${p.subTitle}</td> <td>${p.originalPrice}</td> <td>${p.promotePrice}</td> <td>${p.stock}</td> <td><a href="admin_productImage_list?pid=${p.id}"><span class="glyphicon glyphicon-picture"></span></a></td> <td><a href="admin_propertyValue_edit?pid=${p.id}"><span class="glyphicon glyphicon-th-list"></span></a></td> <td><a href="admin_product_edit?id=${p.id}"><span class="glyphicon glyphicon-edit"></span></a></td> <td><a deleteLink="true" href="admin_product_delete?id=${p.id}"><span class=" glyphicon glyphicon-trash"></span></a></td> </tr> </c:forEach> </tbody> </table> </div> <div class="pageDiv"> <%@include file="../include/admin/adminPage.jsp"%> </div> <div class="panel panel-warning addDiv"> <div class="panel-heading">新增产品</div> <div class="panel-body"> <form method="post" id="addForm" action="admin_product_add"> <table class="addTable"> <tr> <td>产品名称</td> <td><input id="name" name="name" type="text" class="form-control"></td> </tr> <tr> <td>产品小标题</td> <td><input id="subTitle" name="subTitle" type="text" class="form-control"></td> </tr> <tr> <td>原价格</td> <td><input id="originalPrice" value="99.98" name="originalPrice" type="text" class="form-control"></td> </tr> <tr> <td>优惠价格</td> <td><input id="promotePrice" value="19.98" name="promotePrice" type="text" class="form-control"></td> </tr> <tr> <td>库存</td> <td><input id="stock" value="99" name="stock" type="text" class="form-control"></td> </tr> <tr class="submitTR"> <td colspan="2" align="center"> <input type="hidden" name="cid" value="${c.id}"> <button type="submit" class="btn btn-success">提 交</button> </td> </tr> </table> </form> </div> </div> </div> <%@include file="../include/admin/adminFooter.jsp"%>
步骤 17 :

产品缩略图效果

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
产品缩略图效果


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


问答区域    
2021-01-19 关于在list方法查询产品遍历插入分类和图片有些想法
Jesse木子

我的思路是 1 用连接查询一次性查出 该产品和对应的分类 2 在发一条sql 查询所有的图片保存到 集合中 for(遍历产品集合){ 得到循环得第一个产品 for(遍历图片集合){ if(图片的pid==当前遍历得产品的id){ 产品 添加 该图片对象 break; } } } 我认为这样能减少对数据库的消耗 还有种思路就是直接SQL连接查询 全部一起查了




1 个答案

how2j
答案时间:2021-01-22
-__- 那么如果有海量数据,比如上百万,内存放不下怎么办呢



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2020-10-22 请问f_middle怎么理解?中间文件?
加油啊蓁蓁

请问f_middle怎么理解?中间文件?




1 个答案

how2j
答案时间:2020-10-26
文件有3中大小, small middle 和 原大小, middle 就是中等尺寸



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2020-07-30 为什么增加图片后图片没有上传成功
2020-07-10 数据库数据
2020-06-30 为什么不能一次上传多张图片呢?


提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 43 条以前的提问,请 点击查看

提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 实践项目-天猫整站SSM-产品图片管理 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 578362961
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图