I read some struts2 variable in javascript as follows:
<javascript type="text/javascript">
var data='<s:property value="simulationInfos"/>';
<javascript>
If my simulationInfos contains single quote ‘, I get the error : unexpected identifier.
therefore, I tried to escape the quote as follows:
var data='<s:property value="simInfos" escapeJavaScript="true"/>';
and var data='<s:property value="simInfos" escapeHTML="true"/>';
I get the error: Attribute escapeJavaScript (or escapeHTML) invalid for tag property according to TLD.
Any Idea?
Where does the single quote appear? In the value, I’m assuming?
In that case, in your javascript before you perform the struts2 operation, do run this code on the value. This is a regular expression to remove quotations for javascript.
If you need to keep the quotes as URL encoded, do this