StringEscapeUtils escapeHtml

mat*_*ian 5 html escaping stringescapeutils

org.apache.commons.lang.StringEscapeUtils.escapeHtml 和 org.apache.commons.lang3.StringEscapeUtils.escapeHtml4 之间有区别吗?

小智 5

事实上它们来自不同的包

escapeHtml 来自 org.commons.lang (lang 2.5 API),让您使用 writer 对象。它还可以从 SQL 源中转义字符串

escapeHtml4 来自 org.commons.lang3 (lang 3.1 API),专门用于从 HTML4 源转义字符。不多也不少

他们做同样的工作,但我建议使用“escapeHtml4”,因为它来自较新的包

请参阅:EscapeHtml4escapehtml