how2j.cn

下载区
文件名 文件大小
请先登录 1m
增值内容 1m
1m

2分25秒
本视频采用html5方式播放,如无法正常播放,请将浏览器升级至最新版本,推荐火狐,chrome,360浏览器。 如果装有迅雷,播放视频呈现直接下载状态,请调整 迅雷系统设置-基本设置-启动-监视全部浏览器 (去掉这个选项)。 chrome 的 视频下载插件会影响播放,如 IDM 等,请关闭或者切换其他浏览器

步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 效果   
步骤 4 : 编辑超链   
步骤 5 : CategoryMapper.xml   
步骤 6 : CategoryMapper   
步骤 7 : CategoryService   
步骤 8 : CategoryServiceImpl   
步骤 9 : CategoryController   
步骤 10 : editCategory.jsp   

步骤 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 :

CategoryMapper.xml

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.how2java.tmall.mapper.CategoryMapper"> <select id="list" resultType="Category"> select * from category order by id desc <if test="start!=null and count!=null"> limit #{start},#{count} </if> </select> <select id="total" resultType="int"> select count(*) from category </select> <insert id="add" keyProperty="id" useGeneratedKeys="true" parameterType="Category" > insert into category ( name ) values (#{name}) </insert> <delete id="delete"> delete from category where id= #{id} </delete> <select id="get" resultType="Category"> select * from category where id= #{id} </select> </mapper>
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.mapper; import com.how2java.tmall.util.Page; import com.how2java.tmall.pojo.Category; import java.util.List; public interface CategoryMapper { List<Category> list(Page page); int total(); void add(Category category); void delete(int id); Category get(int id); }
package com.how2java.tmall.mapper;

import com.how2java.tmall.util.Page;
import com.how2java.tmall.pojo.Category;

import java.util.List;

public interface CategoryMapper {
     List<Category> list(Page page);

     int total();

     void add(Category category);

     void delete(int id);

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

        import com.how2java.tmall.pojo.Category;
        import com.how2java.tmall.util.Page;
        import java.util.List;

public interface CategoryService{
    int total();
    List<Category> list(Page page);

    void add(Category category);

    void delete(int id);

    Category get(int id);
}
步骤 8 :

CategoryServiceImpl

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service.impl; import com.how2java.tmall.util.Page; import com.how2java.tmall.mapper.CategoryMapper; import com.how2java.tmall.pojo.Category; import com.how2java.tmall.service.CategoryService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class CategoryServiceImpl implements CategoryService { @Autowired CategoryMapper categoryMapper; @Override public List<Category> list(Page page) { return categoryMapper.list(page); } @Override public int total() { return categoryMapper.total(); } @Override public void add(Category category) { categoryMapper.add(category); } @Override public void delete(int id) { categoryMapper.delete(id); } @Override public Category get(int id) { return categoryMapper.get(id); } }
步骤 9 :

CategoryController

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
@RequestMapping("admin_category_edit") public String edit(int id,Model model) throws IOException { Category c= categoryService.get(id); model.addAttribute("c", c); return "admin/editCategory"; }
package com.how2java.tmall.controller; import com.how2java.tmall.pojo.Category; import com.how2java.tmall.service.CategoryService; import com.how2java.tmall.util.ImageUtil; import com.how2java.tmall.util.Page; import com.how2java.tmall.util.UploadedImageFile; 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 org.springframework.web.servlet.ModelAndView; import javax.imageio.ImageIO; import javax.servlet.http.HttpSession; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.List; @Controller @RequestMapping("") public class CategoryController { @Autowired CategoryService categoryService; @RequestMapping("admin_category_list") public String list(Model model,Page page){ List<Category> cs= categoryService.list(page); int total = categoryService.total(); page.setTotal(total); model.addAttribute("cs", cs); model.addAttribute("page", page); return "admin/listCategory"; } @RequestMapping("admin_category_add") public String add(Category c, HttpSession session, UploadedImageFile uploadedImageFile) throws IOException { categoryService.add(c); File imageFolder= new File(session.getServletContext().getRealPath("img/category")); File file = new File(imageFolder,c.getId()+".jpg"); if(!file.getParentFile().exists()) file.getParentFile().mkdirs(); uploadedImageFile.getImage().transferTo(file); BufferedImage img = ImageUtil.change2jpg(file); ImageIO.write(img, "jpg", file); return "redirect:/admin_category_list"; } @RequestMapping("admin_category_delete") public String delete(int id,HttpSession session) throws IOException { categoryService.delete(id); File imageFolder= new File(session.getServletContext().getRealPath("img/category")); File file = new File(imageFolder,id+".jpg"); file.delete(); return "redirect:/admin_category_list"; } @RequestMapping("admin_category_edit") public String edit(int id,Model model) throws IOException { Category c= categoryService.get(id); model.addAttribute("c", c); return "admin/editCategory"; } }
步骤 10 :

editCategory.jsp

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
editCategory.jsp
<%@ 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"%> <title>编辑分类</title> <script> $(function(){ $("#editForm").submit(function(){ if(!checkEmpty("name","分类名称")) return false; return true; }); }); </script> <div class="workingArea"> <ol class="breadcrumb"> <li><a href="admin_category_list">所有分类</a></li> <li class="active">编辑分类</li> </ol> <div class="panel panel-warning editDiv"> <div class="panel-heading">编辑分类</div> <div class="panel-body"> <form method="post" id="editForm" action="admin_category_update" enctype="multipart/form-data"> <table class="editTable"> <tr> <td>分类名称</td> <td><input id="name" name="name" value="${c.name}" type="text" class="form-control"></td> </tr> <tr> <td>分类圖片</td> <td> <input id="categoryPic" accept="image/*" type="file" name="image" /> </td> </tr> <tr class="submitTR"> <td colspan="2" align="center"> <input type="hidden" name="id" value="${c.id}"> <button type="submit" class="btn btn-success">提 交</button> </td> </tr> </table> </form> </div> </div> </div>


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


问答区域    
2020-07-21 出现404错误的先做update修改那一步骤,再回来就可以了
artist244926

出现404错误的先做update修改那一步骤,再回来就可以了




1 个答案

how2j
答案时间:2020-07-22
嗯,要update一下才更新



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




2020-05-23 按步骤做下来的为啥就报了404,还请站长帮忙解答以一下
webxuexi

Type Status Report Message /ishop_ssm/admin_category_update Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.




3 个答案

artist244926
答案时间:2020-07-21
出现404错误的先做update修改那一步骤,再回来就可以了
出现404错误的先做update修改那一步骤,再回来就可以了

岂几
答案时间:2020-05-28
是不是忘了修改controller的代码

how2j
答案时间:2020-05-24
用步骤1,2来定位你哪里写错了



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




2020-03-30 老师问个问题呀,37行这个c.name的这个c的问题
2020-03-17 为什么代码都没问题,就是无法进行编辑
2020-03-14 跳转出现了图片里的问题,请站长指教是什么原因


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

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

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

上传截图