Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

Re: Customizing "content type not allowed" error message

dusty

2009-07-03

Replies: Find Java Web Hosting

Author LoginPost Reply

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@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>

--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.