📄 leavewordaction.java
字号:
package edu.yinhe.mis.control;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import edu.yinhe.mis.dto.LeaveWordDTO;
import edu.yinhe.mis.vo.LeaveWordVO;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.control.BaseAction;
public class LeaveWordAction extends BaseAction {
public ActionForward addLeaveWord(ActionMapping mapping,
HttpServletRequest request, HttpServletResponse response) {
LeaveWordDTO dto = new LeaveWordDTO();
LeaveWordForm form = new LeaveWordForm();
LeaveWordVO vo = new LeaveWordVO();
ActionForward forward = mapping.findForward("input");
try {
BeanUtils.copyProperties(dto, form);
service.setDataSource(this.getDataSource(request));
vo =(LeaveWordVO) service.create(dto);
forward = mapping.findForward("successLeave");
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (AppException e) {
e.printStackTrace();
}
return forward;
}
public ActionForward browseLeaveWord(ActionMapping mapping,
HttpServletRequest request, HttpServletResponse response){
LeaveWordDTO dto = new LeaveWordDTO();
LeaveWordForm form = new LeaveWordForm();
ArrayList list = new ArrayList();
ActionForward forward = mapping.findForward("input");
try {
service.setDataSource(this.getDataSource(request));
list =(ArrayList) service.findAll();
forward = mapping.findForward("successLeave");
} catch (AppException e) {
e.printStackTrace();
}
return forward;
}
public ActionForward deleteLeaveWord(ActionMapping mapping,
HttpServletRequest request, HttpServletResponse response){
ActionForward forward = mapping.findForward("input");
Integer id = Integer.parseInt(request.getParameter("id"));
try {
service.setDataSource(this.getDataSource(request));
service.remove(id);
forward = mapping.findForward("successLeave");
} catch (AppException e) {
e.printStackTrace();
}
return forward;
}
public ActionForward updateLeaveWord(ActionMapping mapping,
HttpServletRequest request, HttpServletResponse response){
LeaveWordDTO dto = new LeaveWordDTO();
LeaveWordForm form = new LeaveWordForm();
LeaveWordVO vo = new LeaveWordVO();
ActionForward forward = mapping.findForward("input");
try {
BeanUtils.copyProperties(dto, form);
Integer id = Integer.parseInt(request.getParameter("hfid"));
dto.setID(id);
service.setDataSource(this.getDataSource(request));
service.modify(dto);
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (AppException e) {
e.printStackTrace();
}
return null;
}
public ActionForward fuhuiLeaveWord(ActionMapping mapping,
HttpServletRequest request, HttpServletResponse response){
ActionForward forward = mapping.findForward("input");
LeaveWordVO vo =new LeaveWordVO();
Integer id = Integer.parseInt(request.getParameter("id"));
try {
service.setDataSource(this.getDataSource(request));
vo =(LeaveWordVO) service.list(id);
if(vo!=null){
request.setAttribute("leave", vo);
forward = mapping.findForward("successLeave");
}
} catch (AppException e) {
e.printStackTrace();
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -