removedepartmentsaction.java

来自「这是本人曾经在公司里用的,内部开发框架,基于struts+hibernate今天」· Java 代码 · 共 54 行

JAVA
54
字号
/**
 * 
 */
package cn.bway.admin.dept.action;

import javax.servlet.http.*;

import org.apache.struts.action.*;

import cn.bway.admin.dept.form.DepartmentsForm;
import cn.bway.admin.dept.impl.DepartmentsManagerFactory;
import cn.bway.common.BwayHibernateException;
import cn.bway.common.WebConstant;
import cn.bway.common.action.BaseAction;

/**
 * @author Kson
 *
 */
public class RemoveDepartmentsAction extends BaseAction {

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) {
		
		DepartmentsForm pForm = (DepartmentsForm) form;
		ActionErrors errors = new ActionErrors();
		String returnStr = WebConstant.FORWARD_SUCCESS;
		try {
			DepartmentsManagerFactory.getDepartmentsManager().deleteDepartments(request.getParameter("checkbox"));
			
			request.setAttribute(WebConstant.RETURN_Message,"删除成功!");
			request.setAttribute(WebConstant.RETURN_URL,"deptlist.do");
		} catch (BwayHibernateException e) {
			returnStr=WebConstant.FORWARD_FAIL;
			errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("edu.system.excption",e.getMessage()));
			this.saveErrors(request,errors);
			e.printStackTrace();
		}
		return mapping.findForward(returnStr);
	}
	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?