如何在jsp中显示带有标签的文本 [英] how to display a text with tags in jsp
本文介绍了如何在jsp中显示带有标签的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示名为
的文字 welcome&to> Jsp
在页面源代码中,我还将其视为welcomeJsp 其单独显示为welcomeJsp。请指导我。
解决方案
您必须转义这些字符。
welcome& lt; to& gt; Jsp
I会使用Apache的 StringEscapeUtils 类(可用于org.apache.commons.lang)函数 escapeHtml()
用于转义HTML。
StringEscapeUtils.escapeHtml(welcome
I want to display a text called
"welcome<to>Jsp"
In page source also i'm seeing as "welcomeJsp"
But in HTML its displaying as "welcomeJsp" alone. Please guide me.
解决方案
You have to escape these characters..
welcome<to>Jsp
I would advice using Apache's StringEscapeUtils class(available in org.apache.commons.lang ) function escapeHtml()
for escaping HTML.
StringEscapeUtils.escapeHtml("welcome<to>Jsp")
这篇关于如何在jsp中显示带有标签的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文