I am having two problems when trying to configure the Struts 2 file upload interceptor in my application. I want to change the maximumSize parameter (the default value is 2 MB, I need it to be 5 MB) and the message resource struts.messages.error.file.too.large (the application locale is pt_BR, so the message is in Portuguese, not in English).
The following application configuration:
struts.properties
struts.locale=pt_BR struts.custom.i18n.resources=MessageResources
struts.xml
<package name="default" namespace="/" extends="struts-default"> <interceptors> <interceptor name="login" class="br.com.probank.interceptor.LoginInterceptor"/> <interceptor-stack name="defaultLoginStack"> <interceptor-ref name="login" /> <interceptor-ref name="defaultStack"/> </interceptor-stack> </interceptors> <default-interceptor-ref name="defaultLoginStack" /> ... </package> ... <package name="proposta" namespace="/proposta" extends="default"> <action name="salvarAnexoProposta" method="salvarAnexoProposta" class="br.com.probank.action.AnexoPropostaAction"> <interceptor-ref name="defaultLoginStack"> <param name="fileUpload.maximumSize">5242880</param> </interceptor-ref> <result name="success">/jsp/listagemAnexosPropostaForm.jsp</result> <result name="input">/jsp/crudAnexoPropostaForm.jsp</result> <result name="error">/jsp/error.jsp</result> <result name="redirect" type="redirect">${redirectLink}</result> </action> </package>
MessageResources.properties
... struts.messages.error.file.too.large=O tamanho do arquivo...
There is nothing special about my Action implementation and my JSP code. They follow the example of http://struts.apache.org/2.1.6/docs/file-upload-interceptor.html . When I try to download a file with more than 5 MB, the application displays the message "the request was rejected because its size (6229458) exceeds the configured maximum (2097152)" - the default message is "Download files" with the maximum default value.
I am trying to put the message resource struts.messages.error.file.too.large in struts-messages.properties, but after that the message has not changed. What is the correct way to configure a file upload interceptor? I am using Struts 2 2.1.7. Thanks in advance.
file-upload configuration struts2 interceptor interceptorstack
matheus.emm
source share