JSP/JSTL functions

[JSP][JSTL functions] fn:escapeXml()

지니★ 2021. 7. 26. 11:37
728x90
728x90
SMALL

 


 

fn:escapeXml()

  • XML 마크업으로 해석될 수 있는 문자를 이스케이프합니다.

 

Syntax

java.lang.String escapeXml(java.lang.String)

 

Example

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
    <head>
        <title>JSTL functions escapeXml</title>
    </head>
    <body>
        <c:set var="str1" value="This is normal String."/>
        <c:set var="str2" value="<a>This is XML String</a>"/>

        <p>With escapeXml() Function</p>
        <p>str1 : ${fn:escapeXml(str1)}</p>
        <p>str2 : ${fn:escapeXml(str2)}</p>

        <p>Without escapeXml() Function:</p>
        <p>str1 : ${str1}</p>
        <p>str2 : ${str2}</p>
   </body>
</html>

 

Result

With escapeXml() Function
str1 : This is normal String.
str2 : <a>This is XML String</a>

Without escapeXml() Function:
str1 : This is normal String.
str2 : This is XML String

 


 

728x90
728x90
LIST