• 大小: 738KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-02
  • 语言: 数据库
  • 标签: ssm  

资源简介

完美的ssm脚手架,数据库mysql内带sql脚本,注解清晰适合学习开发

资源截图

代码片段和文件信息

package com.gert.ssmall.controllers;

import java.io.File;
import java.util.UUID;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.gert.ssmall.entities.Goods;
import com.gert.ssmall.services.GoodsService;

@Controller
@RequestMapping(“/goods“)
public class GoodsController {
    
    @Resource
    GoodsService goodsService;
    
    /*
     * 产品列表与分页Action
     */
    @RequestMapping(“/list“)
    public String list(Model model@RequestParam(required=falsedefaultValue=“1“) int pageNO){
        int size=5;
        model.addAttribute(“size“size);
        model.addAttribute(“pageNO“pageNO);
        model.addAttribute(“count“goodsService.getGoodsCount());
        model.addAttribute(“goods“ goodsService.getGoodsPager(pageNO size));
        return “goods/list“;
    }
    
    /*
     * 删除单个产品对象Action
     */
    @RequestMapping(“/delete/{id}“)
    public String delete(Model model@PathVariable int id@RequestParam(required=falsedefaultValue=“1“) int pageNORedirectAttributes redirectAttributes){
        if(goodsService.delete(id)>0)
        {
            redirectAttributes.addFlashAttribute(“message“ “删除成功!“);
        }else{
            redirectAttributes.addFlashAttribute(“message“ “删除失败!“);
        }
        return “redirect:/goods/list?pageNO=“+pageNO;
    }
    
    /*
     * 删除多个产品对象Action
     */
    @RequestMapping(“/deletes“)
    public String deletes(Model model@RequestParam int[] id@RequestParam(required=falsedefaultValue=“1“) int pageNORedirectAttributes redirectAttributes){
        //执行删除
        int rows=goodsService.deletes(id);
        if(rows>0)
        {
            redirectAttributes.addFlashAttribute(“message“ “删除“+rows+“行记录成功!“);
        }else{
            redirectAttributes.addFlashAttribute(“message“ “删除失败!“);
        }
        return “redirect:/goods/list?pageNO=“+pageNO;
    }
    
    /*
     * 添加商品
     */
    @RequestMapping(“/add“)
    public String add(Model model){
        model.addAttribute(“entity“ new Goods());
        return “goods/add“;
    }
    
    /*
     * 添加商品保存
     */
    @RequestMapping(“/addSave“)
    public String addSave(Model model@ModelAttribute(“entity“) @Valid Goods entityBindingResult bindingResult){
        //如果模型中存在错误
        if(!bindingResult.hasErrors()){
            if(goodsService.insert(entity)>0)
            {
     

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1132  2019-04-17 17:52  goods.sql
     文件        1660  2019-04-16 17:08  SSMall\.classpath
     文件        1082  2019-04-16 17:04  SSMall\.project
     文件         639  2019-04-16 17:04  SSMall\.settings\.jsdtscope
     文件          97  2019-04-17 09:18  SSMall\.settings\org.eclipse.core.resources.prefs
     文件         478  2019-04-16 17:08  SSMall\.settings\org.eclipse.jdt.core.prefs
     文件          90  2019-04-16 17:04  SSMall\.settings\org.eclipse.m2e.core.prefs
     文件         575  2019-04-16 17:09  SSMall\.settings\org.eclipse.wst.common.component
     文件         252  2019-04-16 17:08  SSMall\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2019-04-16 17:04  SSMall\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2019-04-16 17:04  SSMall\.settings\org.eclipse.wst.jsdt.ui.superType.name
     文件          50  2019-04-16 17:04  SSMall\.settings\org.eclipse.wst.validation.prefs
     文件        4983  2019-04-16 17:22  SSMall\pom.xml
     文件        5481  2019-04-17 09:35  SSMall\src\main\java\com\gert\ssmall\controllers\GoodsController.java
     文件        1467  2019-04-16 17:30  SSMall\src\main\java\com\gert\ssmall\entities\Goods.java
     文件         625  2019-04-16 17:37  SSMall\src\main\java\com\gert\ssmall\mapper\GoodsDAO.java
     文件        1167  2019-04-16 17:51  SSMall\src\main\java\com\gert\ssmall\mapper\GoodsMapper.xml
     文件         490  2019-04-16 18:07  SSMall\src\main\java\com\gert\ssmall\services\GoodsService.java
     文件        1231  2019-04-16 18:08  SSMall\src\main\java\com\gert\ssmall\services\GoodsServiceImpl.java
     文件         959  2019-04-16 17:38  SSMall\src\main\java\com\gert\ssmall\test\MyBatisUtil.java
     文件        2272  2019-04-16 18:00  SSMall\src\main\java\com\gert\ssmall\test\TestGoods.java
     文件        3836  2019-04-16 18:04  SSMall\src\main\resources\applicationContext.xml
     文件         219  2019-04-16 18:01  SSMall\src\main\resources\jdbc.properties
     文件        1927  2019-04-16 18:05  SSMall\src\main\resources\MyBatisCfg.xml
     文件        5393  2019-04-17 08:53  SSMall\src\main\resources\springmvc-servlet.xml
     文件          72  2019-04-17 09:34  SSMall\src\main\resources\ValidationMessages.properties
     文件       44139  2019-04-16 19:10  SSMall\src\main\webapp\images\default.jpg
     文件       14204  2019-04-16 19:10  SSMall\src\main\webapp\images\pic(1).jpg
     文件       10093  2019-04-16 19:10  SSMall\src\main\webapp\images\pic(14).jpg
     文件       12305  2019-04-16 19:10  SSMall\src\main\webapp\images\pic(2).jpg
     文件       16665  2019-04-16 19:10  SSMall\src\main\webapp\images\pic(3).jpg
............此处省略42个文件信息

评论

共有 条评论