在 JSP 中,我注意到我无法将 ${} 呈现为 HTML。页面渲染后,HTML 页面将不再显示 ${}。在我看来,${} 是 java 语法的一部分。
有什么方法可以将其呈现为 HTML 吗?目前,我使用 print "${}"作为字符串,这样我就可以在我的 HTML 上呈现它。我需要按原样呈现此符号,以便稍后我可以使用 jquery 获取此符号。 (仅供引用:我正在使用 jquery 模板)
提前致谢
最佳答案
\${this is not an EL expression}
如果表达式出现在 JSP 模板中,则使用 \
对表达式进行转义。
To generate literal values that include the character sequence
${
or#{
, the developer can choose to use a composite expression as shown here:${'${'}exprA} #{'#{'}exprB}
The resulting values would then be the strings
${exprA}
and#{exprB}
.Alternatively, the escape characters
\$
and\#
can be used to escape what would otherwise be treated as an eval-expression. Given the literal-expressions:\${exprA} \#{exprB}
关于javascript - JSP 和 Jquery 中的美元大括号问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9861573/