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; } }
转载于:https://www.cnblogs.com/ZCM98/p/12482400.html
缘于生活,而归于工作。本人所书,而意于分享。
如有转载,请注明出处!
--活出自己范儿