Struts 2/ Foundation 5 - Modeldriven Class And File Upload
Solution 1:
Your problem is that you are defining a wrong Interceptor Stack for your Action.
The default one is defaultStack, while the one you used after the FileUpload Interceptor is the basicStack.
As you can see in the official documentation, the basicStack has no ModelDriven support. Change your action configuration from :
<interceptor-refname="fileUpload"><paramname="allowedTypes">image/jpeg,image/png,image/gif</param><paramname="maximumSize">4194304</param></interceptor-ref><interceptor-refname="basicStack"></interceptor-ref>to :
<interceptor-refname="fileUpload"><paramname="allowedTypes">image/jpeg,image/png,image/gif</param><paramname="maximumSize">4194304</param></interceptor-ref><interceptor-refname="defaultStack"></interceptor-ref>or even better (to avoid using the FileUpload Interceptor twice) to :
<interceptor-refname="defaultStack"><paramname="fileUpload.allowedTypes">image/jpeg,image/png,image/gif</param><paramname="fileUpload.maximumSize">4194304</param></interceptor-ref>Also consider using Struts2 tags to generate the HTML (use simple theme for the maximum control of the generated HTML, or XHTML, the default one, for the maximum assistance in HTML generation).
In many of the tags (the ones with Dynamic Attributes Allowed: true in the documentation), like <s:textfield/>, <s:textarea/>, <s:file/> and so on, you can define your own attributes, like the HTML5 pattern , for example.
The HTML will be cleaner and you will code it faster.
Post a Comment for "Struts 2/ Foundation 5 - Modeldriven Class And File Upload"