Spring Message Tag JavaScript Escape [英] Spring message tag javascript escape

查看:91
本文介绍了Spring Message Tag JavaScript Escape的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们尝试使用spring标签从属性文件中显示标签时,我们可以编写:

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

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

我无法找出javaScriptEscape="true"的用途.我们为什么需要这个?

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

推荐答案

如果消息是JavaScript字符串文字,例如in

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

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

然后,您需要此属性,该属性将转义单引号和双引号,换行符,制表符等,以确保生成的JavaScript有效.

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.

这篇关于Spring Message Tag JavaScript Escape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆