ssh(Spring+Spring mvc+hibernate)——DeptController.java
发布日期:2021-05-14 13:10:57 浏览次数:26 分类:精选文章

本文共 1643 字,大约阅读时间需要 5 分钟。

package org.action;
import java.util.List;
import org.entity.Dept;
import org.service.IDeptService;
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;
@Controller
public class DeptController {
@Autowired
private IDeptService deptService;
@RequestMapping(value = "showDept")
public ModelAndView showDept() {
ModelAndView modelAndView = new ModelAndView("showDept");
List
deptList = deptService.queryAll();
modelAndView.addObject("deptList", deptList);
return modelAndView;
}
@RequestMapping(value = "saveDept")
public ModelAndView saveDept(Dept dept) {
dept.setId((int) (System.currentTimeMillis()));
deptService.saveEntity(dept);
return new ModelAndView("redirect:/showDept.do");
}
@RequestMapping(value = "getDeptById")
public ModelAndView getDeptById(int id) {
ModelAndView modelAndView = new ModelAndView("updateDept");
modelAndView.addObject("dept", deptService.queryById(id));
return modelAndView;
}
@RequestMapping(value = "updateEntity")
public ModelAndView updateEntity(Dept dept) {
deptService.updateEntity(dept);
return new ModelAndView("redirect:/showDept.do");
}
@RequestMapping(value = "delDept")
public ModelAndView delDept(int id) {
Dept dept = deptService.queryById(id);
deptService.delEntity(dept);
return new ModelAndView("redirect:/showDept.do");
}
}
上一篇:ssh(Spring+Spring mvc+hibernate)——EmpController
下一篇:ssh(Spring+Spring mvc+hibernate)——EmpDaoImpl.java

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月28日 20时16分45秒