I have scenario that, I want to upload multiple files, In which User may or may not upload files, And I want to maintain Index at which position user has uploaded file and want to save file with that index as Name
I referred https://stackoverflow.com/a/17050230/3425489 , In my case I don't want to create new class, so not referred Accepted solution
till now In my Action Class I have
File upload [];
String uploadContentType []
String uploadFileName []
getters and setters
In my jsp I tried
<input type="file" name="upload">
but I'm able to get uploaded files only, not able to maintain index
also tried
<input type="file" name="upload[0]">
<input type="file" name="upload[1]">
<input type="file" name="upload[2]">
with this case, I'm not able to setProperties in my Action class
----Updated----
You can refer my Model Struts 2 : Unable to access Model properties in JSP
For your every ProcessSolutionStep, I want to maintain, which file is uploaded for particular step,
i.e. User may upload file for step 1 and step 5, skipping middle steps, and in view.
I want to display file uploaded for particular step
This is How I solved my Problem:
I just post few sample code of my
<tr>tagI have maintained one hidden field
isFileUploadwith inital value 0 , as many no. of my<input type="file">, After uploading file, on its change event I changed value ofisFileUploadto 1 asAnd In my Action Class I have this code
Depending upon values of
isFileUploadi.e. I have checked it with 1,Means I have uploded file at this index position and Mapped with uploaded file array which is
uploads