📄 uploadform.java
字号:
package gov.nist.struts.webapp.upload;import org.apache.struts.upload.FormFile;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionError;import org.apache.struts.action.ActionMapping;import javax.servlet.http.HttpServletRequest;/** * This class is a placeholder for form values. In a multipart request, files are represented by * set and get methods that use the class org.apache.struts.upload.FormFile, an interface with * basic methods to retrieve file information. The actual structure of the FormFile is dependant * on the underlying impelementation of multipart request handling. The default implementation * that struts uses is org.apache.struts.upload.DiskMultipartRequestHandler. * * @author Jean Deruelle * @version $Revision: 1.2 $ $Date: 2004/03/10 21:39:30 $ */public class UploadForm extends ActionForm { /** * The file that the user has uploaded */ protected FormFile theFile=null; /** * The fully qualified name of the main class of the user's service */ protected String path=null; /** * The type of service uploaded (Actually only support Java or SLEE) */ protected String serviceType="Java"; /** * Retrieve a representation of the file the user has uploaded * @return the representation of the file uploaded */ public FormFile getTheFile() { return theFile; } /** * Set a representation of the file the user has uploaded * @param theFile - the representation of the file uploaded */ public void setTheFile(FormFile theFile) { this.theFile = theFile; } /** * Retrieve the fully qualified name of the main class of the user's service * @return The fully qualified name of the main class of the user's service */ public String getPath() { return path; } /** * Set the fully qualified name of the main class of the user's service * @param path - The fully qualified name of the main class of the user's service */ public void setPath(String path) { this.path= path; } /** * Retrieve the type of service which is gonna be uploaded * @return the type of service which is gonna be uploaded */ public String getServiceType() { return serviceType; } /** * Set the type of service which is gonna be uploaded * @param serviceType - the type of service which is gonna be uploaded */ public void setServiceType(String serviceType) { this.serviceType = serviceType; } /** * @see org.apache.struts.action.ActionForm#reset(ActionMapping actionMapping,HttpServletRequest httpServletRequest) */ public void reset(ActionMapping mapping,HttpServletRequest request) { theFile=null; path=null; serviceType="Java"; } /** * @see org.apache.struts.action.ActionForm#validate(ActionMapping mapping,HttpServletRequest request) */ public ActionErrors validate(ActionMapping mapping,HttpServletRequest request){ ActionErrors errors = new ActionErrors(); if ((theFile==null) || (theFile.getFileName()==null) || (theFile.getFileName().length()<1)) errors.add("theFile", new ActionError("upload.error.nofile")); if ((path==null) || (path.length()<1)) path=null; return errors; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -