org.springframework.web.servlet.tags

Class EscapeBodyTag

  • All Implemented Interfaces:
    java.io.Serializable, BodyTag, IterationTag, JspTag, Tag, TryCatchFinally


    public class EscapeBodyTag
    extends HtmlEscapingAwareTag
    implements BodyTag
    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 Summary
    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:
    HtmlUtils, JavaScriptUtils, Serialized Form
    • Constructor Detail

      • EscapeBodyTag

        public EscapeBodyTag()
    • Method Detail

      • setJavaScriptEscape

        public void setJavaScriptEscape(boolean javaScriptEscape)
                                 throws JspException
        Set JavaScript escaping for this tag, as boolean value. Default is "false".
        Throws:
        JspException
      • doInitBody

        public void doInitBody()
        Specified by:
        doInitBody in interface BodyTag
      • readBodyContent

        protected java.lang.String readBodyContent()
                                            throws java.io.IOException
        Read the unescaped body content from the page.
        Returns:
        the original content
        Throws:
        java.io.IOException - if reading failed
      • writeBodyContent

        protected void writeBodyContent(java.lang.String content)
                                 throws java.io.IOException
        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:
        java.io.IOException - if writing failed