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";
    }

    }

  • 相关阅读:
    MySQL之事务
    Java岗 面试考点精讲(基础篇02期)
    Java岗 面试考点精讲(基础篇01期)
    Tomcat热部署
    如何连接局域网的数据库
    Mybatis逆向工程中的 mybatis-generator:generate 代码生成器的使用
    如何把转入成功的XXX.sql导入到自己的数据库里
    JSP知识总结
    Servlet
    Spring学习
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12921351.html
Copyright © 2011-2022 走看看