I'm having a problem uploading a file using spring webflow 1.0 and struts 1.3.
The jsp is 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 is 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 file
field is always null
. The other fields on the form are filled out properly, and if I dig through the RequestContext
, I can find the file is buried deep some of the data structures there.
Here is the horribly ugly way that I can get at the attachment:
// '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've noticed that the MultipartRequestHandler
on my form is null
, and I suspect that this might be part of the problem, but I've tried populating it with an instance of CommonsMultipartRequestHandler
to no avail.
What do I need to do to let the file
field be populated correctly?
I think you should configure spring dispatcher servlet: http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html#mvc-multipart-resolver
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With