Struts2 Multiple File Upload with Map

2019-09-08 04:04发布

问题:

I am doing Multiple file upload with Struts2. It was working fine I map with java static action properties. But I am using Map to collect all the files. I am getting only the file object. I am not getting the fileName and content type.


public class TableListAction extends ActionSupport 
{
    private Map raja;
    public Map getRaja() 
     {
    return raja;
     }
    public void setRaja(Map raja) 
     {
    this.raja = raja;
     }
     public String upload() throws Exception 
     {
        System.out.println(raja);
        return SUCCESS;
    }

} 

My Jsp like this


<s:form enctype="multipart/form-data" method="post" action="upload">
<s:file name="raja['column']"></s:file>
<s:file name="raja['column']"></s:file>
<s:file name="raja['column']"></s:file>
<s:file name="raja['column']"></s:file>
<s:submit/>

During uploading I am getting the file object array in that raja Map but I am not getting the fileName and contenttype.

Thanks in Advance

regards Shreeram A

回答1:


<s:form enctype="multipart/form-data" method="post" action="upload">
<s:file name="raja.column"></s:file>
<s:file name="raja.column"></s:file>
<s:file name="raja.column"></s:file>
<s:file name="raja.column"></s:file>
<s:submit/>

They are append name attribute with FileName and ContentType.

I used before name like this raja['column'], so the result raja['column']FileName and raja['column']ContentType. It wont come into the the Map.

Then i modified raja.column. Then it will append FileName and ContentType correctly like raja.columnContentType and raja.columnFileName

Its work fine now.
Thanks
Shreeram A