去除html字符串内的html标签,只留文本:
- /**
- * 解析一个html字符串,只得到此字符串中的文本
- * @param html
- * @return
- */
- public static String html2txt(String html) {
- //<span style="color: rgb(229, 51, 51); background-color: rgb(0, 153, 0); font-weight: bold; font-style: italic; text-decoration: underline;">测试1</span>
- Document document = Jsoup.parse(html);
- String content = document.text();
- return content;
- }