zoukankan      html  css  js  c++  java
  • 简单的增删改查-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";
    }
    }

  • 相关阅读:
    【转】Android——设置颜色的三种方法
    Eclipse Android安装APP时覆盖安装问题
    自定义数组,实现输出改数组的长度、最大值和最小值
    用程序实现对数组a[45,96,78,6,18,66,50]中的元素进行排序
    PHP面试题2
    PHP面试题
    gulp
    移动端base.css
    笔记
    mouseover和mouseout事件在鼠标经过子元素时也会触发
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12880555.html
Copyright © 2011-2022 走看看