Spring message tag javascript escape

谁都会走 提交于 2019-12-07 02:24:20

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/14782536/spring-message-tag-javascript-escape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!