package com.zm.controller; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.zm.pojo.Admin; import com.zm.pojo.Page; import com.zm.service.AdminService; //告诉springmvc这是一个controller @Controller //设置映射路径 @RequestMapping("") public class AdminController { //装配adminservice @Autowired AdminService adminService; /** * 扫描listAdmin方法返回一个视图mav * @return */ @RequestMapping("listAdmin") public ModelAndView listAdmin(Page page) { ModelAndView mav = new ModelAndView(); PageHelper.offsetPage(page.getStart(),5); List<Admin> cs = adminService.list(); int total = (int) new PageInfo<>(cs).getTotal(); page.caculateLast(total); //视图加入cs集合 mav.addObject("cs", cs); //设置视图模型 mav.setViewName("listAdmin"); return mav; } @RequestMapping("addAdmin") public ModelAndView addAdmin(Admin admin) { adminService.add(admin); return new ModelAndView("redirect:/listAdmin"); } @RequestMapping("deleteAdmin") public ModelAndView deleteAdmin(Admin admin) { adminService.delete(admin); return new ModelAndView("redirect:/listAdmin"); } @RequestMapping("updateAdmin") public ModelAndView updateAdmin(Admin admin) { adminService.update(admin); return new ModelAndView("redirect:/listAdmin"); } @RequestMapping("editAdmin") public ModelAndView editAdmin(Admin admin) { Admin c = adminService.get(admin.getId()); ModelAndView mav = new ModelAndView("editAdmin"); mav.addObject("c", c); return mav; } }
最近下载更多
768881787 LV7
2023年12月25日
李亮 LV19
2023年8月29日
zcx12345678 LV6
2023年5月26日
dsdadg LV1
2023年4月29日
Soratosiro LV6
2022年12月4日
天士大夫 LV2
2022年11月12日
2635474 LV1
2022年6月17日
张真狗 LV9
2022年6月14日
AAAAAF LV5
2022年6月4日
兰文斌 LV6
2022年5月4日
最近浏览更多
adscazsc
3月12日
暂无贡献等级
songsmm LV1
3月11日
minjing123 LV8
1月4日
沈从文 LV2
1月1日
768881787 LV7
2023年12月25日
wwwww816 LV3
2023年12月19日
2775645521 LV4
2023年12月13日
flygrass LV12
2023年12月7日
微信网友_6766536528596992 LV1
2023年12月6日
mds123456 LV2
2023年11月3日