In JSP, I notice that I can't render ${} into HTML. After the page is rendered, the HTML page will not show ${} anymore. In my understanding, ${} is part of java syntax.
Is there any approach to render this into HTML? Currently, I use print "${}" as a string so I can render this on my HTML. I need this symbol to be rendered as it is so later I can grab this symbol using jquery. (FYI: I'm using jquery template)
Thanks in advance
\${this is not an EL expression}
Escape the expression with \\
if it appears in a JSP template.
From the JSP EL 2.2 specification :
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}
You can use \\${expression}. If you are not using EL in that JSP page. then you can use
<%@ page isELIgnored ="true" %>.
I would recommend you to use \\${expression} and use the EL in other part of JSP. EL is very powerful and very helpful.
~Rajiv
将此行放在JSP的顶部。
<%@ page isELIgnored ="true" %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.