日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

ssh(Spring+Spring mvc+hibernate)——EmpController

發(fā)布時間:2023/12/3 javascript 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ssh(Spring+Spring mvc+hibernate)——EmpController 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
/** * @Title: DeptController.java * @Package org.action * @Description: TODO該方法的主要作用: * @author A18ccms A18ccms_gmail_com * @date 2017-12-27 上午10:54:42 * @version V1.0 */ package org.action;import java.text.SimpleDateFormat; import java.util.Date; import java.util.List;import org.entity.Dept; import org.entity.Emp; import org.service.IDeptService; import org.service.IEmpService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView;import sun.beans.editors.IntEditor;import com.sun.beans.editors.DoubleEditor; import com.sun.beans.editors.FloatEditor; import com.sun.beans.editors.LongEditor;/** * * 項目名稱:test_ssh_16qn3 * 類名稱:DeptController * 類描述: * 創(chuàng)建人:Mu Xiongxiong * 創(chuàng)建時間:2017-12-27 上午10:54:42 * 修改人:Mu Xiongxiong * 修改時間:2017-12-27 上午10:54:42 * 修改備注: * @version * */ @Controller public class EmpController {/*** 自動注入Service層*/@Autowiredprivate IEmpService empService;@Autowiredprivate IDeptService deptService;@InitBinder public void initBinder(WebDataBinder binder) { binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true)); binder.registerCustomEditor(int.class, new IntEditor());binder.registerCustomEditor(long.class, new LongEditor()); binder.registerCustomEditor(double.class, new DoubleEditor()); binder.registerCustomEditor(float.class, new FloatEditor()); }/*** * @Description: 該方法的主要作用:顯示所有的員工* @Title: showDept* @param @return 設定文件 * @return 返回類型:ModelAndView * @throws*/@RequestMapping(value="showEmp")public ModelAndView showDept(){ModelAndView modelAndViewContainer = new ModelAndView();List<Emp> empList = empService.queryAll();modelAndViewContainer.addObject("empList",empList);modelAndViewContainer.setViewName("showEmp");return modelAndViewContainer;}/** @Description: 該方法的主要作用:跳轉到添加員工頁面* @Title: saveEntity* @param @param dept* @param @return 設定文件 * @return 返回類型:ModelAndView * @throws*/@RequestMapping(value="upSave")public ModelAndView upSave(){ModelAndView modelAndView = new ModelAndView();List<Dept> deptList = deptService.queryAll();modelAndView.addObject("deptList", deptList);modelAndView.setViewName("saveEmp");return modelAndView;}/** @Description: 該方法的主要作用:添加部門* @Title: saveEntity* @param @param dept* @param @return 設定文件 * @return 返回類型:ModelAndView * @throws*/@RequestMapping(value="saveEmps")public ModelAndView saveEmp(Emp emp){emp.setEid(((Long)System.currentTimeMillis()).intValue());//插入編號//根據(jù)編號查詢部門表Dept dept = deptService.queryById(emp.getDid());emp.setDept(dept);empService.saveEntity(emp);//跳轉到控制器中的getDeptAll方法return new ModelAndView("redirect:/showEmp.do");}/*** * @Description: 該方法的主要作用:根據(jù)編號查詢部門信息* @Title: getDeptById* @param @param id* @param @return 設定文件 * @return 返回類型:ModelAndView * @throws*/@RequestMapping(value="getEmpById")public ModelAndView getEmpById(int id){ModelAndView modelAndView = new ModelAndView();List<Dept> deptList = deptService.queryAll();modelAndView.addObject("emp",empService.queryById(id));modelAndView.addObject("deptList", deptList);modelAndView.setViewName("updateEmp");return modelAndView;}/*** * @Description: 該方法的主要作用:修改部門信息* @Title: updateEntity* @param @param dept* @param @return 設定文件 * @return 返回類型:ModelAndView * @throws*/@RequestMapping(value = "updateEmp")public ModelAndView updateEntity(Emp emp) {// 根據(jù)編號查詢部門表Dept dept = deptService.queryById(emp.getDid());emp.setDept(dept);empService.updateEntity(emp);return new ModelAndView("redirect:/showEmp.do");}/*** * @Description: 該方法的主要作用:刪除部門* @Title: delEntity* @param @param id* @param @return 設定文件 * @return 返回類型:ModelAndView * @throws*/@RequestMapping(value="delEmp")public ModelAndView delEmp(int id) {Emp emp = empService.queryById(id);empService.delEntity(emp);return new ModelAndView("redirect:/showEmp.do");}} 創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結

以上是生活随笔為你收集整理的ssh(Spring+Spring mvc+hibernate)——EmpController的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。