Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts - Uploading Files
    primarykey
    data
    text
    <p>I'm having a problem uploading a file using spring webflow 1.0 and struts 1.3.</p> <p>The jsp is something like this:</p> <pre><code>&lt;html:form action="/flowAction" method="post" enctype="multipart/form-data"&gt; &lt;!-- snip --&gt; &lt;html:file property="file" name="attachDocumentsForm" size="50"/&gt; &lt;!-- snip --&gt; &lt;/html:form&gt; </code></pre> <p>The Form is something like this:</p> <pre><code>public class AttachDocumentsForm extends SpringBindingActionForm { // note, SpringBindingActionForm extends struts' ActionForm private FormFile file; //snip } </code></pre> <p>Now, my problem is that when I submit the form, the <code>file</code> field is always <code>null</code>. The other fields on the form are filled out properly, and if I dig through the <code>RequestContext</code>, I can find the file is buried deep some of the data structures there. </p> <p>Here is the <strong>horribly</strong> ugly way that I can get at the attachment:</p> <pre><code>// 'context' is the RequestContext ServletExternalContext servletExternalContext = (ServletExternalContext) context.getExternalContext(); ActionForm form = (ActionForm) servletExternalContext.getRequest().getAttribute("actionForm"); FormFile file = (FormFile) form.getMultipartRequestHandler().getFileElements().get("file"); </code></pre> <p>I've noticed that the <code>MultipartRequestHandler</code> on my form is <code>null</code>, and I suspect that this might be part of the problem, but I've tried populating it with an instance of <code>CommonsMultipartRequestHandler</code> to no avail.</p> <p>What do I need to do to let the <code>file</code> field be populated correctly?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload