• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jason Hunter's MultipartWrapper and Struts?

 
A Harry
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to use this lib to handle file uploading in my Struts app - has anyone else got this to work?

Reason I ask is the request object that get's passed to the Action "execute" method should be of type "MultipartWrapper" but actually it's "MultipartRequestWrapper"!

Will this work with Struts Action's & how do you get to the uploaded file? or do you have to use a servlet instead of an Action?

This is damm hard work!

thanks

Harry
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts has it's own file upload helpers. If you just define a property of your form bean as type org.apache.struts.upload.FormFile with the same property name used in your <html:file> tag, Struts will automatically map the uploaded file to an instance of this class. There is an example of a file upload in the struts-examples.war file that comes with the Struts download. If you study it, you'll see how it's done.

Once you have a FormFile instance, you can use it's methods to read or write the uploaded file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic