You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Wampole, Garrett C." <gw...@mitre.org> on 2009/07/02 20:40:04 UTC
Customizing "content type not allowed" error message
I'm trying to customize this error message for a file upload form control, and running into problems:
I've created a new properties file named "msgs.properties" with the error message I'd like to show:
struts.messages.error.content.type.not.allowed={1} is not of the correct type
I've placed this file in "WEB-INF/classes" and referenced it in my "struts.properties"
struts.custom.i18n.resources=msgs.properties
I see a log message when deploying to that effect:
INFO: Loading global messages from msgs.properties
In my action, I can even print out the text using the correct key and get my custom message:
getText( "struts.messages.error.content.type.not.allowed" )
However, when I submit a disallowed file using the form, I get the default error message:
Content-Type not allowed: {0} "{1}" "{2}" {3}
I'm using Struts 2.1.6 and I've defined my action method like this:
@Action( value="upload",
results={
@Result( name="success", location="upload.jsp" ) },
interceptorRefs={
@InterceptorRef( value="fileUpload",
params={
"allowedTypes",
"application/zip,application/x-zip-compressed" } ) } )
public String uploadSample()
{
System.out.println(
getText( "struts.messages.error.content.type.not.allowed" ) );
return SUCCESS;
}
Upload.jsp has the s:form tag in it.
Any thoughts appreciated, thanks!
-Garrett
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Customizing "content type not allowed" error message
Posted by dusty <du...@yahoo.com>.
http://struts.apache.org/2.x/docs/localization.html
On this page it says your Action must implement ValidationAware or extend
ActionSupport in order for the error messages to be localized. I am
assuming that is still true when using Convention? How is your Action class
setup?
Wampole, Garrett C. wrote:
>
> I'm trying to customize this error message for a file upload form control,
> and running into problems:
>
> I've created a new properties file named "msgs.properties" with the error
> message I'd like to show:
>
> struts.messages.error.content.type.not.allowed={1} is not of the correct
> type
>
> I've placed this file in "WEB-INF/classes" and referenced it in my
> "struts.properties"
>
> struts.custom.i18n.resources=msgs.properties
>
> I see a log message when deploying to that effect:
>
> INFO: Loading global messages from msgs.properties
>
> In my action, I can even print out the text using the correct key and get
> my custom message:
>
> getText( "struts.messages.error.content.type.not.allowed" )
>
> However, when I submit a disallowed file using the form, I get the default
> error message:
>
> Content-Type not allowed: {0} "{1}" "{2}" {3}
>
> I'm using Struts 2.1.6 and I've defined my action method like this:
>
> @Action( value="upload",
> results={
> @Result( name="success", location="upload.jsp" ) },
> interceptorRefs={
> @InterceptorRef( value="fileUpload",
> params={
> "allowedTypes",
> "application/zip,application/x-zip-compressed" } ) } )
> public String uploadSample()
> {
> System.out.println(
> getText( "struts.messages.error.content.type.not.allowed" )
> );
>
> return SUCCESS;
> }
>
> Upload.jsp has the s:form tag in it.
>
> Any thoughts appreciated, thanks!
> -Garrett
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Customizing-%22content-type-not-allowed%22-error-message-tp24312015p24326609.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org