2022年8月23日
html转译
public static void main(String[] args) { String content = "<h2>这是标题</h2><p>这是文字</p><p><strong>这是加黑文字</strong></p><pre class=\"wp-block-code\"><code>// 这是代码private String test; </code></pre><figure class=\"wp-block-image size-large\"><img src=\"https://scpic.chinaz.net/files/pic/pic9/201311/apic2098.jpg\" alt=\"\"/><figcaption>测试图片</figcaption></figure><p></p>"; System.out.println(content); String s = StringEscapeUtils.escapeHtml4(content); System.out.println(s); String s1 = StringEscapeUtils.unescapeHtml4(s); System.out.println(s1); }
