uploadform.java

来自「基于JAVA的学生就业信息网 实现对信息浏览 检索 审核 修改和删除」· Java 代码 · 共 88 行

JAVA
88
字号
/*
 * Created on 2005-6-16
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.ug.sztz.webview.structs.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.*;
import org.apache.struts.upload.FormFile;
import org.apache.struts.upload.MultipartRequestHandler;

/**
 * @author xix
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class UploadForm extends ActionForm {
	
	    /**
	     * The value of the text the user has sent as form data
	     */
	    protected String theText;

	    /**
	     * The file that the user has uploaded
	     */
	    protected FormFile theFile;

	    /**
	     * Retrieve the value of the text the user has sent as form data
	     */
	    public String getTheText() {
	        return theText;
	    }

	    /**
	     * Set the value of the form data text
	     */
	    public void setTheText(String theText) {
	        this.theText = theText;
	    }

	    /**
	     * Retrieve a representation of the file the user has uploaded
	     */
	    public FormFile getTheFile() {
	        return theFile;
	    }

	    /**
	     * Set a representation of the file the user has uploaded
	     */
	    public void setTheFile(FormFile theFile) {
	        this.theFile = theFile;
	    }

	    /**
	     * Check to make sure the client hasn't exceeded the maximum allowed upload size inside of this
	     * validate method.
	     */
	    public ActionErrors validate(
	        ActionMapping mapping,
	        HttpServletRequest request) {
	            
	        ActionErrors errors = null;
	        //has the maximum length been exceeded?
	        Boolean maxLengthExceeded =
	            (Boolean) request.getAttribute(
	                MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
	                
	        if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
	            errors = new ActionErrors();
	            errors.add(
	                ActionMessages.GLOBAL_MESSAGE ,
	                new ActionMessage("maxLengthExceeded"));
	            errors.add(
	                ActionMessages.GLOBAL_MESSAGE ,
	                new ActionMessage("maxLengthExplanation"));
	        }
	        return errors;

	    }
	}

⌨️ 快捷键说明

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