Escape all strings in JSP/Spring MVC
问题 I display strings in my JSP this way: ${someString} this string may, of course, contain special html characters. Currently it is possible to HTML-inject malicious code (eg. if someString is a javascript include - <script src...> ). How can I make sure that all strings are escaped before printing? I am using Spring MVC and JSP. 回答1: You can use JSTL core : <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> Use <c:out value="${someString}"/> tag to display Strings. <c:out> escapes