Class EscapeBodyTag
java.lang.Object
jakarta.servlet.jsp.tagext.TagSupport
org.springframework.web.servlet.tags.RequestContextAwareTag
org.springframework.web.servlet.tags.HtmlEscapingAwareTag
org.springframework.web.servlet.tags.EscapeBodyTag
- All Implemented Interfaces:
BodyTag,IterationTag,JspTag,Tag,TryCatchFinally,Serializable
The
<escapeBody> tag is used to escape its enclosed body content,
applying HTML escaping and/or JavaScript escaping.
Provides a "htmlEscape" property for explicitly specifying whether to apply HTML escaping. If not set, a page-level default (e.g. from the HtmlEscapeTag) or an application-wide default (the "defaultHtmlEscape" context-param in web.xml) is used.
Provides a "javaScriptEscape" property for specifying whether to apply JavaScript escaping. Can be combined with HTML escaping or used standalone.
| Attribute | Required? | Runtime Expression? | Description |
|---|---|---|---|
| htmlEscape | false | true | Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page. |
| javaScriptEscape | false | true | Set JavaScript escaping for this tag, as boolean value. Default is false. |
- Since:
- 1.1.1
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTEFields inherited from class jakarta.servlet.jsp.tagext.TagSupport
id, pageContextFields inherited from interface jakarta.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAGFields inherited from interface jakarta.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAINFields inherited from interface jakarta.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidprotected intCalled by doStartTag to perform the actual work.protected StringRead the unescaped body content from the page.voidsetBodyContent(BodyContent bodyContent) voidsetJavaScriptEscape(boolean javaScriptEscape) Set JavaScript escaping for this tag, as boolean value.protected voidwriteBodyContent(String content) Write the escaped body content to the page.Methods inherited from class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
htmlEscape, isDefaultHtmlEscape, isHtmlEscape, isResponseEncodedHtmlEscape, setHtmlEscapeMethods inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
doCatch, doFinally, doStartTag, getRequestContextMethods inherited from class jakarta.servlet.jsp.tagext.TagSupport
doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
-
Constructor Details
-
EscapeBodyTag
public EscapeBodyTag()
-
-
Method Details
-
setJavaScriptEscape
Set JavaScript escaping for this tag, as boolean value. Default is "false".- Throws:
JspException
-
doStartTagInternal
protected int doStartTagInternal()Description copied from class:RequestContextAwareTagCalled by doStartTag to perform the actual work.- Specified by:
doStartTagInternalin classRequestContextAwareTag- Returns:
- same as TagSupport.doStartTag
- See Also:
-
doInitBody
public void doInitBody()- Specified by:
doInitBodyin interfaceBodyTag
-
setBodyContent
- Specified by:
setBodyContentin interfaceBodyTag
-
doAfterBody
- Specified by:
doAfterBodyin interfaceIterationTag- Overrides:
doAfterBodyin classTagSupport- Throws:
JspException
-
readBodyContent
Read the unescaped body content from the page.- Returns:
- the original content
- Throws:
IOException- if reading failed
-
writeBodyContent
Write the escaped body content to the page.Can be overridden in subclasses, e.g. for testing purposes.
- Parameters:
content- the content to write- Throws:
IOException- if writing failed
-