Example usage for org.springframework.web.util HtmlUtils htmlEscapeHex

List of usage examples for org.springframework.web.util HtmlUtils htmlEscapeHex

Introduction

In this page you can find the example usage for org.springframework.web.util HtmlUtils htmlEscapeHex.

Prototype

public static String htmlEscapeHex(String input) 

Source Link

Document

Turn special characters into HTML character references.

Usage

From source file:org.springframework.web.util.HtmlUtilsTest.java

/**
 * Test html utils.// w  w  w  .jav a 2s . c  o  m
 */
@Test
public void testHtmlUtils() {
    String specialStr = "<div id=\"testDiv\">test1;test2</div>";
    String str1 = HtmlUtils.htmlEscape(specialStr); //  HTML  HTML ?
    log.info(str1);

    String str2 = HtmlUtils.htmlEscapeDecimal(specialStr);//  HTML  # ????
    log.info(str2);

    String str3 = HtmlUtils.htmlEscapeHex(specialStr);//  HTML  # ????
    log.info(str3);

    // ??????
    log.info(HtmlUtils.htmlUnescape(str1));
    log.info(HtmlUtils.htmlUnescape(str2));
    log.info(HtmlUtils.htmlUnescape(str3));

    log.info(StringEscapeUtils.unescapeHtml4(str1));
    log.info(StringEscapeUtils.unescapeHtml4(str2));
    log.info(StringEscapeUtils.unescapeHtml4(str3));

    log.info(org.apache.commons.lang.StringEscapeUtils.unescapeHtml(str1));
    log.info(org.apache.commons.lang.StringEscapeUtils.unescapeHtml(str2));
    log.info(org.apache.commons.lang.StringEscapeUtils.unescapeHtml(str3));
}