• textarea的换行符处理以及正确的在Html中显示


    /**
     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     }
    

      

  • 相关阅读:
    web框架学习
    css上
    数据库
    线程
    反射以及部分内置方法
    排序函数sort() 和sorted() 之介绍
    类的绑定方法
    继承
    面向对象和类
    混淆矩阵、准确率、召回率
  • 原文地址:https://www.cnblogs.com/hejianrong/p/6873647.html
Copyright © 2020-2023  润新知