91-9990449935 0120-4256464 |
Struts2 File Upload ExampleThe fileUpload interceptor automatically works for all the requests that includes files. We can use this interceptor to control the working of file upload in struts2 such as defining allowed types, maximum file size etc. Parameters of fileupload interceptorThere are 2 parameters defined for fileupload interceptor.
It automatically adds 3 parameters in the request:
Image upload example using struts 2Let's see the directory structure of file upload application. 1) Create UserImage.jspThis jsp page creates a form using struts UI tags. It receives name, password and email id from the user. index.jsp2) Create SuccessUserImage.jspThis jsp page creates a form using struts UI tags. It receives name, password and email id from the user. SuccessUserImage.jsp3) Create the action classThis action class inherits the ActionSupport class and overrides the execute method. RegisterAction.java4) Create struts.xmlThis xml file defines an extra result by the name input, and an interceptor jsonValidatorWorkflowStack. struts.xmlOutputImage will not be displayed in the current project. Visit the image location printed in the server console to see the image.
Next TopicStruts2 Validation Tutorial
|