struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chengas123 <>
Subject Escaping Characters in Struts Property Tag
Date Tue, 13 Nov 2007 18:52:27 GMT

I want to use the struts property tag to set a JavaScript variable. 
Ordinarily, it would look something like:
var testValue = '<s:property value="testValue" />';

However, this does not work if the value has a single quote in it, so that
character needs to be escaped.  It should be easy, but I can't figure out
how to do it.  I can't return testValue.replaceAll("'", "\'") as I'd like to
because the quotes in the call to replaceAll would interfere with the quotes
in property tag.  My only other idea was to create a class with a static
method, but I can't figure out how to call it.  Would it be something like:
var testValue = '<s:property
value="@com.benmccann.util.StringUtil@javascriptEscape(comments)" />'

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message