1

I have a problem with the value staack in Struts 2.

Let's say I have an object called 'Article' and to this article I can upload some photos.

Inputs like this:

<s:file id="file1" name="file1"/>
<s:file id="file2" name="file2"/>
<s:file id="file3" name="file3"/>
<s:file id="file4" name="file4"/>

I fill first file (file1) and submit action. Then I navigate through another action and decide to upload another photo. In the same JSP, I fill second file (file2) and submit.

The problem is that in the in the second submit, in the action, I receive file2, and file1!

Shouldn't valueStack deleted file1 when the first action call finish? I receive and error on method:

ImageIO.read(file)

Because photo can't be read..

Must I clean the value stack myself after action finish with an interceptor?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Toni Montero
  • 113
  • 1
  • 6
  • 2
    No. It's more likely you're not scoping your actions via Spring correctly--they should be prototype scope, not singletons. It's also not clear why you'd fill in file2 if the file1 field is empty, but that's a separate issue. – Dave Newton Feb 25 '14 at 18:50
  • 1
    Oh god...! I Forgot that default scope in spring context it's singleton. I must configure scope for each bean defined in context according with each action. Thank you very much Dave! Resolved! – Toni Montero Feb 26 '14 at 09:08

0 Answers0