Spring Boot + Thymeleaf Tag JAVA CUSTOM UTIL 사용

2023. 6. 27. 08:57웹개발/Spring Boot

728x90
@Component
public class CustomUtils {
    public static String removeTag(String html) throws Exception {
        return html.replaceAll("<(/)?([a-zA-Z]*)(\\s[a-zA-Z]*=[^>]*)?(\\s)*(/)?>", "");
    }
}
 
자바 Class 에 Component 추가 후
 
Thymeleaf 에서 
 
<span th:text="${@customUtils.removeTag(list.content)}"></span>

이런 식으로 사용할 수 있다.

728x90
반응형