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;
 }
 
posted @ 2012-06-05 10:01  attilaxAti  阅读(7)  评论(0编辑  收藏  举报