• 多对一的增删改查-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";
    }

    }

  • 相关阅读:
    HDU-1240 Asteroids! (BFS)这里是一个三维空间,用一个6*3二维数组储存6个不同方向
    HDU-1026 Ignatius and the Princess I(BFS) 带路径的广搜
    HDU-1700 Points on Cycle
    HDU-4515 小Q系列故事——世界上最遥远的距离
    Star
    HDOJ5441(图论中的并查集)
    HDOJ5438(图的各个连通分量遍历)
    HDOJ5044(最近公共祖先)
    C++输入输出知识
    JAVAmap容器基本使用
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12921351.html
Copyright © 2020-2023  润新知