问题
Before I go and create a custom tag or Java method to do it, what is the standard way to escape HTML characters in JSP?
I have a String object and I want to display it in the HTML so that it appears to the user as is.
For example:
String a = "Hello < World";
Would become:
Hello < World
回答1:
Short answer:
<c:out value="${myString}"/>
there is another option:
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
${fn:escapeXml(myString)}
来源:https://stackoverflow.com/questions/475839/how-can-i-escape-special-html-characters-in-jsp