Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring message tag javascript escape

When we try to display a label from a properties file, using spring tags, we can write:

<spring:message javaScriptEscape="true" code="label" />

i am not able to find out what is the use of javaScriptEscape="true". Why do we need this?

like image 864
Victor Avatar asked Feb 08 '13 22:02

Victor


1 Answers

If the message is a JavaScript string literal, such as in

<script>
    function sayI18nedHello() {
        alert('<spring:message javaScriptEscape="true" code="hello" />');
    }
</script>

Then you need this attribute, which will escape the single and double quotes, the newline chars, the tabs, etc. in order to make sure that the generated JavaScript is valid.

like image 138
JB Nizet Avatar answered Sep 30 '22 16:09

JB Nizet