Hi Dirk,
I had the same problem and after spending the whole day trying things
out, I found something that works.
In WEB-INF/classes I created a class struts-messages.properties with
following content:
struts.messages.error.uploading=Fehler beim hochladen der Datei
struts.messages.error.file.too.large=Die Datei ist zu groß!
struts.messages.error.content.type.not.allowed = Der Dateityp wird
leider nicht unterstützt.
In my strus.properties I added:
struts.multipart.parser=org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest
struts.multipart.maxSize=100000000
struts.custom.i18n.resources=struts-messages
My action-definition looks like:
<action name="SaveSettings" class="saveSettings">
<interceptor-ref name="fileUpload">
<param name="allowedTypes">
image/x-png,image/png,image/gif,image/jpeg,image/pjpeg
</param>
<param name="maximumSize">120000
</param>
</interceptor-ref>
[...]
</action>
It seems like that the value in struts.multipart.maxSize is passed to
commons-fileupload. If the uploaded file exceeds this value, the message
you mentioned is displayed. BUT: if we set this value quite high (so
that commons-fileupload is not complaining about it), the Struts
FileUploadInterceptor checks again for the parameter maximumSize, which
is passed in the action-definition. (In my case I don't want to have
files bigger than 120000 bytes.) If the file-size exceeds this value,
the message declared in struts.messages.error.file.too.large is loaded.
This behaviour is really annoying and it took an eternity to find it
out. So let me know if this is working for you.
Greetings from Flensburg,
Joachim
Dirk Schumacher schrieb:
Hello,
I am troubleling with the Fileupload in S2.
I want to have printed my own messages on failure of the file upload
which takes place in the interceptor.
I am uploading files exceeding the set maximum size
The documentation talks about the struts-message-properties, where is
declared:
struts.messages.error.uploading=Error uploading: {0}
struts.messages.error.file.too.large=File too large: {0} "{1}" {2}
struts.messages.error.content.type.not.allowed=Content-Type not allowed:
{0} "{1}" {2}
The message printed via the ActionError is complete different text I
cannot find in any file:
"the request was rejected because its size (2352563) exceeds the
configured maximum (2097152)"
Where is this Text declared?
A colleague talked about the commons-fileupload which is declaring the
printed text....
The Jakarta File... seems to me the right instance of takiong care of
the ActionError
When looking at the sources I figured that not the FileUploadInterceptor
instantiates the ActionError. It is done by the
parse()-Method of the MultipartRequestWrapper, or somewhere deeper.
So figure that the struts-message.properties is never applied and the
ActionError is setup in-code instead of the usage of an external
property file.
Is there any documentation out there on this issue? - I just want to set
my own (localed) messages for the different errors that may occure, just
like intended by the S2 FileUploadInterceptor, which seems somewhat not
fully useful to me right now.
I appreciate your help in advance,
best greetings from cologne,
Dirk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 270.4.0/1506 - Release Date: 17.06.2008 16:30
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]