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

    }

  • 相关阅读:
    随机过程之第一次出现的期望
    js模板引擎介绍搜集
    qt的安装和debug
    $parse/$eval和$observe/$watch如何区分
    angular controller as syntax vs scope
    Angularjs Controller 间通信机制
    Ng-template寄宿方式
    angularjs移除不必要的$watch
    angularJs项目实战!02:前端的页面分解与组装
    推荐几个可以与PhoneGap很好搭配的UI框架
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12921351.html
Copyright © 2011-2022 走看看