| 
 步骤 1 : 先运行,看到效果,再学习 步骤 2 : 模仿和排错 步骤 3 : 效果 步骤 4 : 编辑超链 步骤 5 : CategoryMapper.xml 步骤 6 : CategoryMapper 步骤 7 : CategoryService 步骤 8 : CategoryServiceImpl 步骤 9 : CategoryController 步骤 10 : editCategory.jsp 
				
					
						增值内容,请先登录
					
				
				 
					
					完整的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项目经验,为简历加上一个有吸引力的砝码.
					 增值内容,点击购买 
					使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
					 
				
					
						增值内容,请先登录
					
				
				 
					
					完整的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);
}
				
					
						增值内容,请先登录
					
				
				 
					
					完整的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);
    }
}
 
				
					
						增值内容,请先登录
					
				
				 
					
					完整的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";
    }
}
 
				
					
						增值内容,请先登录
					
				
				 
					
					完整的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"%>
<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修改那一步骤,再回来就可以了 
					
					
						
							
						
											
							
					
					
					
	   
 
		回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢	
	 
	  		
	  
	  	2020-05-23
	  		
	  				
	  					 
	  
					
						按步骤做下来的为啥就报了404,还请站长帮忙解答以一下 
					
					
						
							
						
											
							
					
					
					
	   
 
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 条以前的提问,请 点击查看 
			
			提问之前请登陆
			
		 
		提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢	
	 | |||||||||||||||||