日期:2014-05-16 浏览次数:20658 次
点我下载工程代码 package?com.ajaxfile.action;
由于项目需求,在处理文件上传时需要使用到文件的异步上传。这里使用Jquery Ajax File Uploader这个组件下载地址:http://www.phpletter.com/download_project_version.php?version_id=6
服务器端采用struts2来处理文件上传。
所需环境:
jquery.js
ajaxfileupload.js
struts2所依赖的jar包
及struts2-json-plugin-2.1.8.1.jar
编写文件上传的Action
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileOutputStream;
import?org.apache.struts2.ServletActionContext;
import?com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public?class?FileAction?extends?ActionSupport?{
????private?File?file;
????private?String?fileFileName;
????private?String?fileFileContentType;
????private?String?message?=?"你已成功上传文件";
????
????public?String?getMessage()?{
????????return?message;
????}
????public?void?setMessage(String?message)?{