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

📄 uploadaction.java

📁 负责公文的传输及一些处理功能
💻 JAVA
字号:
//Created by MyEclipse Struts// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.1/xslt/JavaClass.xslpackage com.example.web.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 com.jspsmart.upload.*;import com.jspsmart.*;import com.example.gw.attachment.IAttachmentManager;import com.example.gw.attachment.Attachment;/**  * MyEclipse Struts * Creation date: 03-23-2007 *  * XDoclet definition: * @struts.action validate="true" */public class UploadAction extends Action {	// --------------------------------------------------------- Instance Variables	// --------------------------------------------------------- Methods	private IAttachmentManager attachmentManager;	public void setAttachmentManager(IAttachmentManager attachmentManager){		this.attachmentManager = attachmentManager;	}	public IAttachmentManager getAttachmentManager(){		return attachmentManager;	}	/** 	 * Method execute	 * @param mapping	 * @param form	 * @param request	 * @param response	 * @return ActionForward	 */	public ActionForward execute(		ActionMapping mapping,		ActionForm form,		HttpServletRequest request,		HttpServletResponse response) {		  try{			    SmartUpload upload = new SmartUpload();//			    upload.initialize(getServlet().getServletConfig(),request,response);			    try{			      upload.upload();			    }catch(NegativeArraySizeException e) {}			    Request req = upload.getRequest();			    String Id = request.getParameter("Id");			    String unitId=request.getParameter("unitId");			    Attachment bean=attachmentManager.getAttachment(Id);			    String title=bean.getFileName();			    title=title.substring(0,title.lastIndexOf("."));			    String type = request.getParameter("type");			    com.jspsmart.upload.File file = upload.getFiles().getFile(0);			    if(!file.isMissing()) {			      if(type.equals("0")){			        file.saveAs(bean.getPath()+bean.getSite()+"/"+title+".gw");			      }			      if(type.equals("1")){			        file.saveAs(bean.getPath()+bean.getSite()+"/"+title+".gd");			      }			      if(type.equals("2")){			        file.saveAs(bean.getPath()+bean.getSite()+"/"+title+"("+unitId+")"+".gd");			      }			    }			  }catch(Exception e){			    e.printStackTrace();			  }		// TODO Auto-generated method stub		return null;	}}

⌨️ 快捷键说明

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