我在JSP中工作,在这方面我还是个新手。我需要将单个aposthropy更改为'或',并使用StringEscapeUtils.escapeHtml将两个aposthropy更改为"或"。编译成功。但它并没有起作用。
这是我的测试代码。
<%= StringEscapeUtils.escapeHtml("cool 4' product") %>
在查看页面源代码中,结果为:
cool 4' product
不
cool 4' product.
怎么了?我怎么才能修复它呢?谢谢。
发布于 2014-12-10 16:40:23
引用https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml%28java.lang.String%29中的StringEscapeUtils.escapeHtml javadoc
支持所有已知的HTML4.0实体,包括时髦的重音。请注意,常用的撇号转义字符(')不是合法实体,因此不受支持)。
发布于 2015-12-11 14:55:49
使用:
StringEscapeUtils.escapeHtml("I'm coder")
使用HTML实体转义字符串中的字符。
例如:
"bread" & "butter"
变成:
"bread" & "butter".
https://stackoverflow.com/questions/26154614
复制相似问题