更新时间:2022-11-22 11:58:32
如果要将字符串转换为HTML实体以快速进行测试,则可以使用如下所示的Web服务:
If you want to convert a string to HTML entities to test something quickly, you can use webservices like this one:
http://www.primitivetype.com/resources/htmlentities.php
对于Java,您可以使用Apache Commons Lang中的StringEscapeUtils.看到这个线程:在Java中转义HTML的推荐方法
For Java you can use the StringEscapeUtils from Apache Commons Lang. See this thread: Recommended method for escaping HTML in Java
import static org.apache.commons.lang.StringEscapeUtils.escapeHtml;
// ...
String source = "The less than sign (<) and ampersand (&) must be escaped before using them in HTML";
String escaped = escapeHtml(source);
我从上述线程中借用了示例.
I borrowed the example from the thread mentioned above.