File upload Struts 2中的NullPointException上载文件

File upload Struts 2中的NullPointException上载文件,file-upload,configuration,struts2,struts2-interceptors,interceptorstack,File Upload,Configuration,Struts2,Struts2 Interceptors,Interceptorstack,我正在尝试使用表单上传一个文件,我正在遵循互联网上的一个教程。使用此代码,我收到一个NullPointerException 这是index.jsp: 文件上传 上传你的文件 这是success.jsp(如果上传成功): 文件上传成功 您已成功上载 行动类: import java.io.File; import org.apache.commons.io.FileUtils; import java.io.IOException; import c

我正在尝试使用表单上传一个文件,我正在遵循互联网上的一个教程。使用此代码,我收到一个
NullPointerException

这是index.jsp:


文件上传
上传你的文件

这是success.jsp(如果上传成功):


文件上传成功
您已成功上载
行动类:

    import java.io.File;
    import org.apache.commons.io.FileUtils;
    import java.io.IOException; 

    import com.opensymphony.xwork2.ActionSupport;

    public class uploadFile extends ActionSupport{
    private File myFile;
    private String myFileContentType;
    private String myFileFileName;
    private String destPath;

      public String execute()
   {
                    /* Copy file to a safe location */
               destPath = "C:/apache-tomcat-6.0.33/work/";

      try{
         System.out.println("Src File name: " + myFile);
         System.out.println("Dst File name: " + myFileFileName);

         File destFile  = new File(destPath, myFileFileName);
         FileUtils.copyFile(myFile, destFile);

      }catch(IOException e){
         e.printStackTrace();
         return ERROR;
      }

      return SUCCESS;
   }
        public File getMyFile() {
        return myFile;
    } 
        public void setMyFile(File myFile) {
         this.myFile = myFile;
   }
   public String getMyFileContentType() {
      return myFileContentType;
   }
   public void setMyFileContentType(String myFileContentType) {
      this.myFileContentType = myFileContentType;
   }
   public String getMyFileFileName() {
      return myFileFileName;
   }
   public void setMyFileFileName(String myFileFileName) {
      this.myFileFileName = myFileFileName;
   }
}
Struts.xmf配置文件:


图像/jpeg,图像/gif
/success.jsp
/error.jsp

注意:
error.jsp
相当于
success.jsp
,正文中只打印不同的消息。

FileUpload
拦截器必须在
BasicStack
拦截器堆栈之前运行

改变这个


图像/jpeg,图像/gif
对此


图像/jpeg,图像/gif

发布堆栈跟踪。