码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2020-03-12 20:32:31      阅读:62      评论:0      收藏:0      [点我收藏+]

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

package 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   

原文地址:https://www.cnblogs.com/ZCM98/p/12482400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!