富文本字符串过滤标签

<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
</dependency>

 

 

Page<CmsArticle> cmsArticleList = cmsArticleService.findPage(pageDTO);
cmsArticleList.forEach(item -> {
String content = Jsoup.parse(item.getContent()).text();
// 截取前120位
Integer contentLength = content.length();
content = content.substring(0, contentLength >= 120 ? 120 : contentLength);
item.setContent(content+"...");
});

posted @ 2021-11-22 14:48  教练我想打篮球  阅读(155)  评论(0编辑  收藏  举报