⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 group1saveaction.java

📁 通过Tomcat实现服务器的功能然后进行实现 这是一个个人通讯管理系统
💻 JAVA
字号:
package com.relationinfo.txl.struts.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.relationinfo.txl.dao.Group1Dao;
import com.relationinfo.txl.dto.Group1;
import com.relationinfo.txl.factory.Group1DaoFactory;
import com.relationinfo.txl.struts.forms.Group1Form;

public class Group1SaveAction extends Action
{
	/**
	 * Method 'execute'
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @throws Exception
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		try {
			// cast the form to the appropriate type
			Group1Form group1Form = (Group1Form) form;
		
			//创建Dao类
			Group1Dao dao = Group1DaoFactory.create();
		
			Group1 dto = new Group1();
			dto.setGroupid( group1Form.getGroupid());
			dto.setGroupname( group1Form.getGroupname());
		
			if (group1Form.getCrudMethod().equalsIgnoreCase("insert")) {
				dao.insert( dto );
			} else if (group1Form.getCrudMethod().equalsIgnoreCase("update")) {
				dao.update( dto.createPk(), dto );
			} else if (group1Form.getCrudMethod().equalsIgnoreCase("delete")) {
				dao.delete( dto.createPk() );
			}
		
			return mapping.findForward( "success" );
		}
		catch (Exception e) {
			ActionErrors _errors = new ActionErrors();
			_errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage() ) );
			saveErrors( request, _errors );
			return mapping.findForward( "failure" );
		}
		
	}

}

⌨️ 快捷键说明

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