HTML 인코딩 이스케이프, HTML 태그를 서로 이스케이프

611 단어 html 태그
org.springframework.web.util.HtmlUtils는 HTML 태그와 이스케이프 문자 간의 변환을 지원합니다.
코드는 다음과 같습니다.

/** HTML   **/
String s = HtmlUtils.htmlEscape("<div>hello world</div><p>&nbsp;</p>");
System.out.println(s);
String s2 = HtmlUtils.htmlUnescape(s);
System.out.println(s2);

출력의 결과는 다음과 같습니다.

&lt;div&gt;hello world&lt;/div&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;

<div>hello world</div><p>&nbsp;</p>

좋은 웹페이지 즐겨찾기