Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在包含字符序列 ${} (OpenLayers 样式 - 属性替换语法)的 GSP 中编写一些 javascript。不幸的是,这也是 groovy gstring 表达式的语法。如何转义它,以便 Grails 不会将字符序列解释为 gstring。我试过'\',但没有奏效。
我通常这样做的方式是
${'${test}'}
或者
${'$'}{test}
请注意使用单引号而不是双引号 -${"${test}"}不起作用,因为内部${}将被解释为 GString 而不是文字。
${"${test}"}
${}
尝试这个:
alert("\$\{test\}");
输出:
${test}