Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4782

Struts2.5.10.1 upload photo file can't set success

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.5.10
    • None
    • Core
    • Windows10 ,jdk1.7.80, struts2.5.10.1

    Description

      Hi ,today i found my application can't upload file success,Could you help me check it?

      I have do it follow the guide:
      http://struts.apache.org/docs/file-upload.html
      the error message as below :

      Unexpected Exception caught setting 'upload' on 'class com.opensymphony.xwork2.ActionSupport: Error setting expression 'upload' with value ['org.apache.struts2.dispatcher.multipart.StrutsUploadedFile@22261709', ]
      ERROR ParametersInterceptor Developer Notification (set struts.devMode to false to disable this message):
      Unexpected Exception caught setting 'uploadContentType' on 'class com.opensymphony.xwork2.ActionSupport: Error setting expression 'uploadContentType' with value ['image/jpeg', ]
      ERROR ParametersInterceptor Developer Notification (set struts.devMode to false to disable this message):
      Unexpected Exception caught setting 'uploadFileName' on 'class com.opensymphony.xwork2.ActionSupport: Error setting expression 'uploadFileName' with value ['tabletennis_head.jpg', ]
      

      index.jsp

      <div class="row">
      		<div class="col-md-12">
      			<s:actionerror cssClass="alert alert-error" />
      			<s:fielderror cssClass="alert alert-error" />
      			<s:form action="appUploadHeadPhotoAction.do"
      				method="POST" enctype="multipart/form-data">
      				<s:file name="upload" label="File" />
      				<s:submit cssClass="btn btn-primary" />
      			</s:form>
      		</div>
      	</div>
      

      Action file:

      	private File upload;
      	private String uploadContentType;
      	private String uploadFilename;
      
      	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) {
      		this.uploadFilename = uploadFilename;
      	}
      
      	public String execute() {
      
      		System.out.println("--------haaaaaaaaaa-----start---------------");
      		System.out.println(upload);
      		System.out.println(uploadContentType);
      		System.out.println(uploadFilename);
      		System.out.println("--------haaaaaaaaaa------end--------------");
      		return SUCCESS;
      
      	}
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            fairy fairy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: