public static String htmlToString(String str)
{
if(str==null) return "";
if(str.equals("")) return "";
str = str.replaceAll("&", "&");
str = str.replaceAll("<", "<");
str = str.replaceAll(">", ">");
str = str.replaceAll("&amp;", "&");
str = str.replaceAll("&quot;", """);
str = str.replaceAll("\"", """);
str = str.replaceAll("&lt;", "<");
str = str.replaceAll("&gt;", ">");
str = str.replaceAll("&nbsp;", " ");
return str;
}
public static String stringToHtml(String str)
{
if(str==null) return "";
if(str.equals("")) return "";
str = str.replaceAll("&", "&");
str = str.replaceAll("<", "<");
str = str.replaceAll(">", ">");
str = str.replaceAll(">", ">");
str = str.replaceAll(""", "\"");
str = str.replaceAll(" ", " ");
return str;
}
String与HTML转换
最新推荐文章于 2022-08-30 13:52:10 发布