tags:

views:

54

answers:

1

I am using Struts2 fileUpload interceptor to upload the files. I have configured the maxSize, allowed contentTypes ... props etc. But when user violate the maxSize ... Struts2 display error message which is very long string ...

I want to change the message string i.e. how I can override struts.messages.error.file.too.large ... any idea?

Thanks!

+1  A: 

You can define the custom error messages in your existing message resource .properties file(s) for the class or globally:

struts.messages.error.uploading=Upload error.
struts.messages.error.file.too.large=Uploaded file was too large.
struts.messages.error.content.type.not.allowed=File type is not allowed.
struts.messages.error.file.extension.not.allowed=File extension is not allowed.

If you're not currently using .properties files to store your text, the docs have a good section on using and configuring Message Resource Files.

Pat