ae8a2826d066e164b5658237e238173f3e109e30.svn-base 754 B

1234567891011121314151617181920212223242526272829
  1. package org.jeecg.common.util;
  2. import org.apache.commons.lang3.StringUtils;
  3. import org.springframework.web.util.HtmlUtils;
  4. /**
  5. * HTML 工具类
  6. */
  7. public class HTMLUtils {
  8. /**
  9. * 获取HTML内的文本,不包含标签
  10. *
  11. * @param html HTML 代码
  12. */
  13. public static String getInnerText(String html) {
  14. if (StringUtils.isNotBlank(html)) {
  15. //去掉 html 的标签
  16. String content = html.replaceAll("</?[^>]+>", "");
  17. // 将多个空格合并成一个空格
  18. content = content.replaceAll("(&nbsp;)+", "&nbsp;");
  19. // 反向转义字符
  20. content = HtmlUtils.htmlUnescape(content);
  21. return content.trim();
  22. }
  23. return "";
  24. }
  25. }