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

📄 uploadaction.java

📁 开发的一个java web的任务管理系统。
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package unicom.action;

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

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 org.apache.struts.upload.FormFile;
import unicom.factory.*;
/*
 * @author:xiaogang
 * 功能:完成文件上传到服务器,并保存到数据库中
 */

import unicom.bean.Operator;
import unicom.factory.ServiceFactory;
import unicom.service.IMobileService;
import unicom.service.IOperService;
/**
 * @author xiaogang
 * 日期:Apr 18, 2008
 * 功能:低端控制器,完成文件上传并将内容保存到数据库中
 * 优点:
 * 缺点:
 * 建议:
 */
public class UploadAction extends IdentityFilter {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		if(super.isAdminLogin(request))
		{
		//造型表单,获得FormFile
		DynaActionForm dyForm = (DynaActionForm)form;
		FormFile theFile = (FormFile)dyForm.get("file");
		//设置服务器端的文件保存路径
		String filePath = request.getRealPath("") + "/temp.txt";
		System.out.println(filePath);
		//通过静态工厂方法获得业务bean
		IMobileService mobileService = ServiceFactory.createMobileService();
		boolean success =mobileService.addFileContentToDB(theFile, filePath);
		if(success)
		{
			//成功将文本文件内容导入数据库,跳转到成功提示页面
			request.setAttribute("msg", "恭喜,成功导入数据库");
			return mapping.findForward("msgpage");
		}else{
			//成功将文本文件内容导入数据库,跳转到成功提示页面
			request.setAttribute("msg", "已经存在部分电话号码");
			return mapping.findForward("msgpage");
		}
		}
		
		else{
			request.setAttribute("msg", "你还没有登陆");
			return mapping.findForward("index");
		}
	
	}
}

⌨️ 快捷键说明

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