• 简单的增删改查-controller


    package com.lzl.controller;

    import java.util.List;

    import org.apache.dubbo.config.annotation.Reference;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.PostMapping;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;

    import com.github.pagehelper.PageInfo;
    import com.lzl.pojo.Shop;
    import com.lzl.service.ShopService;

    @Controller
    public class Shopcontroller {

    @Reference
    ShopService service;

    @RequestMapping("long")
    public String select(Model m, @RequestParam(defaultValue = "1") Integer pageNum,
    @RequestParam(defaultValue = "3") Integer pageSize) {

    PageInfo<Shop> info = service.select(pageNum, pageSize);
    List<Shop> list = info.getList();
    for (Shop shop : list) {
    System.out.println(shop);
    }
    m.addAttribute("info", info);
    return "list";

    }

    @ResponseBody
    @RequestMapping("del")
    public Object del(String sids) {

    boolean flag = service.del(sids);
    return flag;
    }

    @GetMapping("toAdd")
    public String toAdd(Model model, Shop shop) {
    model.addAttribute("shop", shop);
    return "add";
    }
    /**
    * 添加
    * @param shop
    * @return
    */
    @PostMapping("add")
    public String add(Shop shop) {

    service.add(shop);
    return "redirect:long";
    }

    @GetMapping("/toupdate")
    public String toupdate(Integer sid, Model m) {

    Shop shop = service.selectOne(sid);
    System.err.println(shop);
    m.addAttribute("shop", shop);
    return "update";
    }
    /**
    * 修改
    * @param shop
    * @return
    */
    @PostMapping("update")
    public String update(Shop shop) {

    service.update(shop);
    return "redirect:long";
    }
    }

  • 相关阅读:
    MATLAB矩阵操作【z】
    matlab绘图方法[z]
    Drawhere 有趣的网页涂鸦工具【z】
    DemoHelper,针对电脑演示的小工具
    Matlab Matrix [z]
    MATLAB函数参考[z]
    计算几何常用算法概览[z]
    matlab命令行环境的常用操作[z]
    不常见数学符号或简写
    matlab加入上级路径和本级路径的方法
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12880555.html
Copyright © 2020-2023  润新知