HTML转义JAVA代码

 public static String html(String content) {
     if(content==null) return "";        
     String html = content;
     
     html = html.replace( "'", "'");
     html = html.replaceAll( "&", "&");
     html = html.replace( "\"", """);  //"
     html = html.replace( "\t", "  ");// 替换跳格
     html = html.replace( " ", " ");// 替换空格
     html = html.replace("<", "&lt;");
 
     html = html.replaceAll( ">", "&gt;");
   
     return html;
 }

你可能感兴趣的:(HTML转义JAVA代码)