帮小弟看个struts2上传文件报错信息,,在线等!!!
前台jsp:
<form action="<%=basePath%>m/file/uploadFile.action" method="post" enctype="multipart/form-data">
<p><input type="text" name="fileName" id="fileName" value=""></input>File Description</p>
<p><input type="file" name="upload" id="upload" value="file"></input></p>
<p><input type="submit" value="UpLoad"></input></p>
</form>
struts配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.i18n.encoding" value="utf-8"/>
<constant name="struts.multipart.maxSize" value="-1"/>
<constant name="struts.multipart.saveDir" value="/tmp"/>
<package name="file" namespace="/m/file" extends="json-default">
<global-results>
<result type="json">
<param name="ignoreHierarchy">false</param>
<!-- 输出父类属性 -->
<param name="excludeNullProperties">true</param>
<!-- 排除空属性 -->
</result>
<result name="error" type="json">
<param name="ignoreHierarchy">false</param>
<param name="includeProperties">msg,msg.code,msg.text</param>
</result>
</global-results>
<action name="uploadFile" class="fileUpLoadAction" method="fileUpload">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">image/bmp, image/tmp, image/xml, image/x-png, image/gif, image/jpeg</param>
<param name="maximumSize">204800</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="input">/index.jsp</result>
<param name="savePath">/upload</param>
<result>/page/UpLoad.jsp</result>
</action>
</package>
</struts>
后台action:
package com.start.action;
import java.io.*;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.start.upload.FileFiler;
public class FileUpLoadAction extends ActionSupport {
// private FileFiler file;
//
// public FileFiler getFile() {
// return file;
// }
//
// public void setFile(FileFiler file) {
// this.file = file;
// }
private String fileName;
private File upload;
private String uploadContentType;
private String uploadFileName;
private String savePath;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getUploadContentType() {
return uploadContentType;
}
public void setUploadContentType(String uploadContentType) {
this.uploadContentType = uploadContentType;
}
public String getUploadFileName() {
return uploadFileName;
}
public void setUploadFileName(String uploadFileName) {