html文本存入数据库,特殊字符转换
package Controller; public class TranslationStr { public String HtmltoStr(String newText) { // newText = newText.replace("\n", "<br>"); //textBox里的换行是用\n来表示的,如果要在HTML里显示换行要用<br> newText = newText.replace("<", "<"); //置换 < newText = newText.replace(">", ">"); //置换 > newText=newText.replace("/", "&frasl"); return newText; } public String StrtoHtml(String newText) { //newText = newText.replace("<br>", "\n"); newText = newText.replace("<", "<"); newText = newText.replace(">", ">"); newText=newText.replace("&frasl","/"); return newText; } }