Identifying each field in Multiple File upload

前端 未结 2 533
别跟我提以往
别跟我提以往 2021-01-28 06:22

When trying to upload multiple files with Struts2 using ArrayList, how to identify each field?

For example, if I have two file fields, File1 a

2条回答
  •  不思量自难忘°
    2021-01-28 06:46

    Name each field with different names and create corresponding accessors to action properties. Then each of them will handle the name by OGNL and set corresponding properties. Try with different approach create list or map for the files indexed by iterator tag.

     
      
    
    
    
    

    in action

    private List fileUpload = new ArrayList();
    

    also accessors should be for each property

    then you will know which of them uploaded by checking the file at the list index. You could also try with the Map.

     
      
    
    
    
    

    in action

    private Map fileUpload = new HashMap();
    

    what is better suits your needs

提交回复
热议问题