0

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.

Community
  • 1
  • 1
user2663337
  • 87
  • 1
  • 9

2 Answers2

2

Since comment was too long so i am answering your question.

struts.xml

<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.

Umesh Awasthi
  • 23,407
  • 37
  • 132
  • 204
1

You will find the answer to your question here.

I've already use it past time. Tell us if it's work for you

Community
  • 1
  • 1
Pracede
  • 4,226
  • 16
  • 65
  • 110
  • I already mentioned I tried that, and the outside link present in the answer doesn't match my version of struts. – user2663337 Aug 13 '13 at 08:09