struts2 利用fileupload实现文件上传

struts2实现文件上传

struts配置:




	
	
	
	
 		
		
	
			

				  
					image/bmp,image/png,image/gif,image/jpeg,image/jpg,image/x-png, image/pjpeg  
				
				
                512 
				
			  
			
				result
			
		
		
	

jsp代码:

	
测试

action代码:

package com.frank.server.bis.action;

import java.io.File;

import org.springframework.stereotype.Controller;

/**
 * 
 *@descr: 
 *@className: UploadAction
 *@author: frank
 *@email: [email protected]
 *@date: Jan 17, 2014
 */
@Controller
public class UploadAction {
	private boolean result = false;
	  private File icon; //上传的文件
	    private String iconFileName; //文件名称
	    private String iconContentType; //文件类型

	public String upload(){
		result = true;
		System.out.println(icon);
		System.out.println(getIconContentType());
		return "success";
	}
	public boolean isResult() {
		return result;
	}
	public void setResult(boolean result) {
		this.result = result;
	}
	public File getIcon() {
		return icon;
	}
	public void setIcon(File icon) {
		this.icon = icon;
	}
	public String getIconFileName() {
		return iconFileName;
	}
	public void setIconFileName(String iconFileName) {
		this.iconFileName = iconFileName;
	}
	public String getIconContentType() {
		return iconContentType;
	}
	public void setIconContentType(String iconContentType) {
		this.iconContentType = iconContentType;
	}
	
	
	
}


你可能感兴趣的:(struts)