Reputation: 87
The struts.messages.error.file.too.large
or struts.messages.error.content.type.not.allowed
keys would pose interest to me. I've already tried to put them in a "global.properties"
, "struts-messages.properties"
, and "ActionName_en_US.properties"
file and I have not seen either one of the messages that I wrote. I have three <s:file>
fields in a form and the action to which it is submitted has the interceptors:
<interceptor-ref name="fileUpload">
<param name="maximumSize">2097152</param>
<param name="allowedTypes">
image/png,image/gif,image/jpeg,image/pjpeg
</param>
</interceptor-ref>
<interceptor-ref name="secureStack"></interceptor-ref>
The secureStack
interceptor does not throw any errors.
EDIT: here's the definition of it:
<interceptor name="authenticationInterceptor"
class="client.interceptors.Authentication" />
<interceptor-stack name="secureStack">
<interceptor-ref name="authenticationInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
I used THIS ANSWER and it seems to work but when one file exceeds the maximum size, the error message appears on the other two fields also.
Upvotes: 0
Views: 1991
Reputation: 23587
Since comment was too long so i am answering your question.
<constant name="struts.custom.i18n.resources" value="global" />
you can put any other properties / constant in your xml file
create a global.properties
file with following
struts.messages.error.file.too.large=message
struts.messages.error.uploading=message
struts.messages.error.content.type.not.allowed=message
place this property file in same location as your struts.xml
file.
Just make sure to clean & build before deploying and running. I am sure it should work.
Upvotes: 2