当前位置:Gxlcms > 数据库问题 > html文本存入数据库,特殊字符转换

html文本存入数据库,特殊字符转换

时间:2021-07-01 10:21:17 帮助过:37人阅读

Controller; public class TranslationStr { public String HtmltoStr(String newText) { // newText = newText.replace("\n", "<br>"); //textBox里的换行是用\n来表示的,如果要在HTML里显示换行要用<br> newText = newText.replace("<", "&lt"); //置换 < newText = newText.replace(">", "&gt"); //置换 > newText=newText.replace("/", "&frasl"); return newText; } public String StrtoHtml(String newText) { //newText = newText.replace("<br>", "\n"); newText = newText.replace("&lt", "<"); newText = newText.replace("&gt", ">"); newText=newText.replace("&frasl","/"); return newText; } }

 

html文本存入数据库,特殊字符转换

标签:col   字符转换   html文本   replace   ati   数据库   htm   数据   div   

人气教程排行