Question

I have rather silly problem. Struts2 property tag doesn't escape single quote ('). Such behavior breaks my JavaScript code. It does do escape double quote (") using html entities, but not single quote ('). Is there any possibility to force property tag to replace single quote with appropriate html entity?

Example, string replaced with html entities. Отредактированное событие с кавычкой "

The same with single qoute: Отредактированное событие с кавычкой '

Is there any possibility to overcome such difficulty using standard approach? I wouldn't like to write some custom code.

Was it helpful?

Solution

You're in luck! By default, the tag only escapes HTML, but you can have it escape JavaScript too:

<s:property value="yourValue" escapeJavaScript="true"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top