Reputation:
In my struts.xml I have:
<action name="file_save" method="fileSave" class="FileActionBean">
<interceptor-ref name="fileUpload">
<param name="maximumSize">
5242880
</param>
<param name="allowedTypes">
text/html
</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result name="success" type="redirect">file</result>
<result name="error">error</result>
</action>
When I upload a file that's bigger than 5MB then no error is thrown. Then at the top of my struts.xml I have:
<constant name="struts.multipart.maxSize" value="20971520" />
Now when I upload a file that's bigger than 20MB then an error message is shown. Is this normal behaviour?
If so, how can I configure struts to show error messages for interceptors too?
EDIT 1:
I'm using struts 2 version 2.1.8.1
Upvotes: 1
Views: 810
Reputation:
I had a similar problem in this post:
How do you override Struts 2 Messages?
I found that by following this example I resolved both this issue and the one above.
Upvotes: 1
Reputation: 802
why don't you take your file size validation code to your action class then in validation method check for file size and if it violates then addActionError("your msg")
and display it in your jsp.
<constant name="struts.multipart.maxSize" value="-1"/>
try this with your struts constant and set interceptor file size to your desired size.
Upvotes: 0