简体   繁体   中英

how to get HTML tags without rendering from ${model} in spring

i have comment field where i can enter comment, consider am entering html tag like

<h1> hello </h1>

when page is loading its showing as

hello

and rendering <h1> tag.

how to Stop page from rendering HTML tags

Am using jsp page with jstl to dispay comment.

 textarea class="dropdownlist" id="commentbox" onkeyup="isMaxLength(this,500)">${view.data['comment']} 

You may use JSTL c:out tag:

<c:out value="${view.data['comment']}" />

or JSTL fn:escapeXML function:

${fn:escapeXml(view.data['comment'])}

Of course, you should add proper taglib directive to JSP (see documentation )

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM