struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre Metras" <>
Subject Re: Can't obtain quote characters from struts message file
Date Sun, 05 Nov 2000 20:01:03 GMT
Thanks Michael,

The behavior of ' in Struts messages resources was turning me crazy.
Particularly when a resource string was used to localize javascript code,
where I use single quotes as string separator and frequently had syntax
errors due to quotes disappearing from the retrieved string.

Now, I have found in java.text.MessageFormat that the quote character is
used as escape char in format string. And Struts processes the strings from
the resource for argument substitution... Thus this strange and undocumented
(in Struts) behavior.

Perhaps a quote from the JDK doc could be added in the <struts:message>
    In strings, single quotes can be used to quote the "{" (curly brace) if
necessary. A real single quote is represented by ''. Inside a
messageFormatElement, quotes are not removed

Thanks again.

Pierre Metras

----- Original Message -----
From: "Michael Westbay" <>
To: <>
Sent: Saturday, November 04, 2000 10:38 AM
Subject: Re: Can't obtain quote characters from struts message file

> M騁ras-san wrote:
> > I posted this problem one month ago but I've only found a strange
> > Are other having such a behavior?
> >
> > My tomcat+struts web application reads message tag strings from a
> > file. In the default message file, that contains French sentences for
> > moment, when the messages contains quotes ( ' ), these quotes disapear
> > the HTML page. I traced the problem to the function reading the messages
> > from the property file.
> > [...]
> > As a last test, I tried to double the quote as in "l''蜊ission" (that's
> > quotes, and not a double-quote). And then it worked! I have "l'蜊ission"
> > the displayed HTML page.
> Are you putting this string through a java.text.MessageFormat.format(...)
> function?  I've had this problem with format()ed strings read from
> ResourceBundles in the past.  It's the MessageFormat that causes the
> quotes to require the two single quotes to escape.  When I don't put the
> string through the MessageFormat.format() function, doubling single quotes
> aren't required.
> --
> Michael Westbay
> Work: Beacon-IT
> Home: 
> Commentary:

View raw message