0

Inside my JSP, I simply print out my content as follows:

${article.body}

Of course, any HTML tags within that object are rendered, and that's expected behaviour. However within this content, I want to show everything within a <pre> tag as plain text.

I know HTML can be escaped by using ${fn:escapeXML(article.body)} or <c:out value="${article.body}" />, but that will escape all the HTML, whereas I just need everything inside the <pre> tag to be escaped.

I am using Java to generate the contents, and JSP as the view.

Any help would be greatly appreciated.

4

1 回答 1

0

Your could try using jsoup to make the content safe before sending to the jsp.

http://jsoup.org/ allows many levels of escaping.

You code find the text in your servlet and then send it to be escaped using jsoup or similar.

于 2013-09-06T00:19:20.987 回答