/** 2 * Html转换为TextArea文本 3 * @return 4 */ 5 public static String HtmlToText(String str) { 6 if (str == null) { 7 return ""; 8 }else if (str.length() == 0) { 9 return ""; 10 } 11 str = str.replaceAll("<br />", " "); 12 str = str.replaceAll("<br />", " "); 13 return str; 14 } 15 16 /** 17 * TextArea文本转换为Html:写入数据库时使用 18 */ 19 public static String Text2Html(String str) { 20 if (str == null) { 21 return ""; 22 }else if (str.length() == 0) { 23 return ""; 24 } 25 str = str.replaceAll(" ", "<br />"); 26 str = str.replaceAll(" ", "<br />"); 27 return str; 28 }