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

Parameters are not injected when upload file

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.3.16
    • Fix Version/s: 2.3.28
    • Component/s: Core Interceptors
    • Labels:
      None

      Description

      import java.io.File;
      
      import org.apache.struts2.ServletActionContext;
      
      import com.opensymphony.xwork2.ActionSupport;
      
      public class UploadAction extends ActionSupport {
      
      	private static final long serialVersionUID = 625509291613761721L;
      
      	private File[] file;
      
      	private String[] fileFileName;
      
      	private String folder;
      
      	private boolean autorename;
      
      	public boolean isAutorename() {
      		return autorename;
      	}
      
      	public void setAutorename(boolean autorename) {
      		this.autorename = autorename;
      	}
      
      	public void setFolder(String folder) {
      		this.folder = folder;
      	}
      
      	public String getFolder() {
      		return folder;
      	}
      
      	public void setFile(File[] file) {
      		this.file = file;
      	}
      
      	public void setFileFileName(String[] fileFileName) {
      		this.fileFileName = fileFileName;
      	}
      
      	@Override
      	public String execute() {
      
      		System.out.println(file); // not null
      		System.out.println(fileFileName); // not null
      
      		System.out.println(folder); // always null
      		System.out.println(autorename); // always false
      
      		// workaround for struts2 bug
      		folder = ServletActionContext.getRequest().getParameter("folder");
      		autorename = "true".equals(ServletActionContext.getRequest()
      				.getParameter("autorename"));
      
      		System.out.println(folder); // not null
      		System.out.println(autorename); // true
      
      		return SUCCESS;
      	}
      
      }
      
      

      It works fine with 2.3.16.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                quaff Yanming Zhou
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: