java后台删除html标签的方法

来源:互联网 发布:淘宝海外全球购 编辑:程序博客网 时间:2024/05/16 01:57
页面上的文本框可能会输入一些html标签,比如"<br>","<p></p>"等,这个时候需要过滤掉public static String replaceHtml(String html) {    if (html != null && !"".equals(html)) {        String regEx = "<.+?>"; // 表示标签        Pattern p = Pattern.compile(regEx);        Matcher m = p.matcher(html);        String s = m.replaceAll("");        return s;    } else        return "";}
原创粉丝点击