java - How to override struts 2.2.3.1 file upload messages? -
the struts.messages.error.file.too.large
or struts.messages.error.content.type.not.allowed
keys pose interest me. i've tried put them in "global.properties"
, "struts-messages.properties"
, , "actionname_en_us.properties"
file , have not seen either 1 of messages wrote. have three <s:file>
fields in form , action submitted has 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 not throw errors.
edit: here's 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 , seems work when 1 file exceeds maximum size, error message appears on other 2 fields also.
since comment long answering question.
struts.xml
<constant name="struts.custom.i18n.resources" value="global" />
you can put other properties / constant in xml file
create global.properties
file following
struts.messages.error.file.too.large=message struts.messages.error.uploading=message struts.messages.error.content.type.not.allowed=message
place property file in same location struts.xml
file. make sure clean & build before deploying , running. sure should work.
Comments
Post a Comment