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.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;

    import com.github.pagehelper.PageInfo;
    import com.lzl.pojo.Company;
    import com.lzl.pojo.Pantent;
    import com.lzl.service.PantentService;

    @Controller
    public class PantentController {

    @Reference
    PantentService service;

    @RequestMapping("list")
    public String list(Model m,@RequestParam(defaultValue = "1")Integer pageNum,@RequestParam(defaultValue = "5")Integer pageSize,Pantent pantent) {

    PageInfo<Pantent> info = service.list(pageNum, pageSize,pantent);
    Pantent pz = service.zong();

    m.addAttribute("info", info);
    m.addAttribute("pz", pz);
    m.addAttribute("pantent", pantent);

    return "list";
    }

    @RequestMapping("toadd")
    public String toadd(Model m) {


    List<Company> coms = service.coms();
    m.addAttribute("coms", coms);

    return "add";
    }
    @RequestMapping("add")
    public String add(Pantent pantent) {
    service.add(pantent);//执行添加

    return "redirect:list";
    }

    @RequestMapping("tongji")
    public String tongji(Model m) {
    List<Pantent> list = service.tongji();
    m.addAttribute("list", list);

    return "tongji";
    }
    @RequestMapping("toupdate")
    public String toupdate(Model m,Integer id) {
    System.out.println(id);
    Pantent pantent = service.selectOne(id);//查询单个数据
    List<Company> coms = service.coms();//查询
    m.addAttribute("coms", coms);
    m.addAttribute("pantent", pantent);
    return "update";

    }
    @RequestMapping("update")
    public String update(Pantent pantent) {
    service.update(pantent);//修改

    return "redirect:list";
    }

    }

  • 相关阅读:
    Vue 计算属性(四)
    Vue 方法与事件(三)
    Vue 基本指令使用(二)
    Vue 项目开发环境搭建(一)
    SpringBoot 整合 Dubbo
    Nginx 中 include 指令使用
    Nginx 中 root 和 alias 的使用区别
    JS动态修改网站图标以及标题
    vue中使用轮播图插件carousel,克隆的图片点击事件无效的解决办法
    根据 url + fileName下载文件,并更改文件名
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12921351.html
Copyright © 2011-2022 走看看