Dollar braces in JSP and jQuery

In JSP, I notice that I cannot display $ {} in HTML. After displaying the page, the HTML page will no longer display $ {}. In my understanding, $ {} is part of the java syntax.

Is there any approach for rendering in HTML? I am currently using print "$ {}" as a string, so I can do this in my HTML. I need this character to be displayed, since I can capture this character later using jquery. (FYI: I am using a jquery template)

Thanks in advance

+4
source share
3 answers
\${this is not an EL expression} 

Close the expression with \ if it appears in the JSP template.

From JSP EL 2.2 specification :

To generate literal values โ€‹โ€‹that include the sequence of characters ${ or #{ , the developer can choose to use a compound expression, as shown here:

 ${'${'}exprA} #{'#{'}exprB} 

The resulting values โ€‹โ€‹are the strings ${exprA} and #{exprB} .

Alternatively, the escape characters \$ and \# can be used to avoid what would otherwise be considered an eval expression. Given literal expressions:

 \${exprA} \#{exprB} 
+5
source

You can use \ $ {expression}. If you are not using EL on this JSP page. then you can use <% @page isELIgnored = "true"%>.

I would recommend using \ $ {expression} and using EL in another part of JSP. EL is very powerful and very useful.

~ Rajiv

+2
source

Put this line at the top of your JSP.

 <%@ page isELIgnored ="true" %> 
+1
source

Source: https://habr.com/ru/post/1403331/


All Articles