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

📄 empaddactionaction.java

📁 简单的员工管理
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.business.EmpBusiness;
import com.struts.form.EmpForm;
import java.io.*;;

/** 
 * MyEclipse Struts
 * Creation date: 06-06-2008
 * 
 * XDoclet definition:
 * @struts.action path="/empAddAction" name="empForm" input="/emplist.jsp" scope="request" validate="true"
 */
public class EmpAddActionAction extends Action {
	/*
	 * Generated Methods
	 */

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		//DynaActionForm empForm = (DynaActionForm) form;// TODO Auto-generated method stub
		EmpForm empForm=(EmpForm) form;
		
		/*
		 * 获得上传照片信息
		 * */
		//获取照片名称
		String fname=empForm.getFl().getFileName();
		
		empForm.setPicture(fname);
		//获取网站物理路径
		String path=request.getRealPath("");
		File f=new File(path+"/upfile/"+fname);
		System.out.println("》——————————————"+path);
		try {
			//创建文件输出流
			FileOutputStream fos=new FileOutputStream(f);
			// 写入文件
			fos.write(empForm.getFl().getFileData());
			fos.flush();
			fos.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
		//保存用户信息
		EmpBusiness ebuss=new EmpBusiness();
		boolean bl=ebuss.save(empForm);
		if(bl)
		{
			return mapping.findForward("addok");
		}
		return null;
		
	}
}

⌨️ 快捷键说明

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