Struts - File Download

I have a problem downloading a file using spring webflow 1.0 and struts 1.3.

jsp looks something like this:

<html:form action="/flowAction" method="post" enctype="multipart/form-data">
    <!-- snip -->
    <html:file property="file" name="attachDocumentsForm" size="50"/>
    <!-- snip -->
</html:form>

The form looks something like this:

public class AttachDocumentsForm extends SpringBindingActionForm {
    // note, SpringBindingActionForm extends struts' ActionForm
    private FormFile file;
    //snip
}

Now my problem is that when I submit the form, the field is filealways null. Other fields on the form fill out correctly, and if I dig RequestContext, I can find a file that is deeply littered with some data structures.

Here's a terribly ugly way I can get when embedding:

// 'context' is the RequestContext
ServletExternalContext servletExternalContext = (ServletExternalContext) context.getExternalContext();
ActionForm form = (ActionForm) servletExternalContext.getRequest().getAttribute("actionForm");
FormFile file = (FormFile) form.getMultipartRequestHandler().getFileElements().get("file");

I noticed that MultipartRequestHandlerin my form null, and I suspect that this may be part of the problem, but I tried filling it with an instance to CommonsMultipartRequestHandlerno avail.

What do I need to do so that the field is filefilled in correctly?

+5
2

FormFile ActionForm (, attachDocumentsForm), .

, form.getFile().

, !

0

All Articles