## org.springframework.web.servlet.tags.form
Class ErrorsTag

    java.lang.Object
      javax.servlet.jsp.tagext.TagSupport
          org.springframework.web.servlet.tags.RequestContextAwareTag
              org.springframework.web.servlet.tags.HtmlEscapingAwareTag
                  org.springframework.web.servlet.tags.form.AbstractFormTag
                      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
                          org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
                              org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag
                                  org.springframework.web.servlet.tags.form.ErrorsTag

All Implemented Interfaces:
  Serializable, BodyTag, DynamicAttributes, IterationTag, JspTag, Tag, TryCatchFinally, EditorAwareTag

    public class ErrorsTag

extends AbstractHtmlElementBodyTag
implements BodyTag

Form tag for displaying errors for a particular field or object.

This tag supports three main usage patterns:

1. Field only - set '`path`' to the field name (or path)
2. Object errors only - omit '`path`'
3. All errors - set '`path`' to '`*`'

Since:
  2.0
Author:
  Rob Harrop, Juergen Hoeller, Rick Evans
See Also:
  Serialized Form

Field Summary
`static String` `MESSAGES_ATTRIBUTE` The key under which this tag exposes error messages in the `page context scope`.
`static String` `SPAN_TAG` The HTML '`span`' tag.

Fields inherited from class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag
`CLASS_ATTRIBUTE, DIR_ATTRIBUTE, LANG_ATTRIBUTE, ONCLICK_ATTRIBUTE, ONDBLCLICK_ATTRIBUTE, ONKEYDOWN_ATTRIBUTE, ONKEYPRESS_ATTRIBUTE, ONKEYUP_ATTRIBUTE, ONMOUSEDOWN_ATTRIBUTE, ONMOUSEMOVE_ATTRIBUTE, ONMOUSEOUT_ATTRIBUTE, ONMOUSEOVER_ATTRIBUTE, ONMOUSEUP_ATTRIBUTE, STYLE_ATTRIBUTE, TABINDEX_ATTRIBUTE, TITLE_ATTRIBUTE`

Fields inherited from class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
`COMMAND_NAME_VARIABLE_NAME, NESTED_PATH_VARIABLE_NAME`

Fields inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
`logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE`

Fields inherited from class javax.servlet.jsp.tagext.TagSupport
`pageContext`

Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
`EVAL_BODY_BUFFERED, EVAL_BODY_TAG`

Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
`EVAL_BODY_AGAIN`

Fields inherited from interface javax.servlet.jsp.tagext.Tag
`EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE`

Constructor Summary
`ErrorsTag()`

Method Summary
`protected String` `autogenerateId()` Get the value for the HTML '`id`' attribute.
`protected void` `exposeAttributes()` Exposes any bind status error messages under `this key` in the `PageContext.PAGE_SCOPE`.
`String` `getDelimiter()` Return the delimiter to be used between error messages.
`String` `getElement()` Get the HTML element must be used to render the error messages.
`protected String` `getName()` Get the value for the HTML '`name`' attribute.
`protected void` `removeAttributes()` Removes any bind status error messages that were previously stored under `this key` in the `PageContext.PAGE_SCOPE`.
`protected void` `renderDefaultContent(TagWriter tagWriter)`
`void` `setDelimiter(String delimiter)` Set the delimiter to be used between error messages.
`void` `setElement(String element)` Set the HTML element must be used to render the error messages.
`protected boolean` `shouldRender()` Should rendering of this tag proceed at all?

Methods inherited from class org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag
`doEndTag, doFinally, doInitBody, flushBufferedBodyContent, onWriteTagContent, renderFromBodyContent, setBodyContent, writeTagContent`

Methods inherited from class org.springframework.web.servlet.tags.form.AbstractHtmlElementTag

`getCssClass, getCssErrorClass, getCssStyle, getDir, getDynamicAttributes, getLang, getOnclick, getOndblclick, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getTabindex, getTitle, isValidDynamicAttribute, resolveCssClass, setCssClass, setCssErrorClass, setCssStyle, setDir, setDynamicAttribute, setLang, setOnclick, setOndblclick, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setTabindex, setTitle, writeDefaultAttributes, writeOptionalAttributes`

Methods inherited from class org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
`convertToDisplayString, getBindStatus, getBoundValue, getEditor, getId, getNestedPath, getPath, getPropertyEditor, getPropertyPath, processFieldValue, resolveId, setId, setPath`

Methods inherited from class org.springframework.web.servlet.tags.form.AbstractFormTag
`createTagWriter, doStartTagInternal, evaluate, evaluateBoolean, getDisplayString, getDisplayString, isDefaultHtmlEscape, writeOptionalAttribute`

Methods inherited from class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
`isHtmlEscape, setHtmlEscape`

Methods inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
`doCatch, doStartTag, getRequestContext`

Methods inherited from class javax.servlet.jsp.tagext.TagSupport
`doAfterBody, findAncestorWithClass, getParent, getValue, getValues, release, removeValue, setPageContext, setParent, setValue`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface javax.servlet.jsp.tagext.BodyTag
`doInitBody, setBodyContent`

Methods inherited from interface javax.servlet.jsp.tagext.IterationTag
`doAfterBody`

Methods inherited from interface javax.servlet.jsp.tagext.Tag
`doEndTag, doStartTag, getParent, release, setPageContext, setParent`

Field Detail

### MESSAGES_ATTRIBUTE

    public static final String MESSAGES_ATTRIBUTE

  The key under which this tag exposes error messages in the `page context scope`.

  See Also:
    Constant Field Values

### SPAN_TAG

    public static final String SPAN_TAG

  The HTML '`span`' tag.

  See Also:
    Constant Field Values

Constructor Detail

### ErrorsTag

    public ErrorsTag()

Method Detail

### setElement

    public void setElement(String element)

  Set the HTML element must be used to render the error messages.

  Defaults to an HTML '`<span/>`' tag.

### getElement

    public String getElement()

  Get the HTML element must be used to render the error messages.

### setDelimiter

    public void setDelimiter(String delimiter)

  Set the delimiter to be used between error messages.

  Defaults to an HTML '`<br/>`' tag.

### getDelimiter

    public String getDelimiter()

  Return the delimiter to be used between error messages.

### autogenerateId

    protected String autogenerateId()
                             throws JspException

  Get the value for the HTML '`id`' attribute.

  Appends '`.errors`' to the value returned by `AbstractDataBoundFormElementTag.getPropertyPath()` or to the model attribute name if the `<form:errors/>` tag's '`path`' attribute has been omitted.

  Overrides:
    `autogenerateId` in class `AbstractDataBoundFormElementTag`
  Returns:
    the value for the HTML '`id`' attribute
  Throws:
    `JspException`
  See Also:
    `AbstractDataBoundFormElementTag.getPropertyPath()`

### getName

    protected String getName()
                      throws JspException

  Get the value for the HTML '`name`' attribute.

  Simply returns `null` because the '`name`' attribute is not a validate attribute for the '`span`' element.

  Overrides:
    `getName` in class `AbstractDataBoundFormElementTag`
  Returns:
    the value for the HTML '`name`' attribute
  Throws:
    `JspException`

### shouldRender

    protected boolean shouldRender()
                            throws JspException

  Should rendering of this tag proceed at all?

  Only renders output when there are errors for the configured `path`.

  Overrides:
    `shouldRender` in class `AbstractHtmlElementBodyTag`
  Returns:
    `true` only when there are errors for the configured `path`
  Throws:
    `JspException`

### renderDefaultContent

    protected void renderDefaultContent(TagWriter tagWriter)
                                 throws JspException

  Specified by:
    `renderDefaultContent` in class `AbstractHtmlElementBodyTag`
  Throws:
    `JspException`

### exposeAttributes

    protected void exposeAttributes()
                             throws JspException

  Exposes any bind status error messages under `this key` in the `PageContext.PAGE_SCOPE`.

  Only called if `shouldRender()` returns `true`.

  Overrides:
    `exposeAttributes` in class `AbstractHtmlElementBodyTag`
  Throws:
    `JspException`
  See Also:
    `removeAttributes()`

### removeAttributes

    protected void removeAttributes()

  Removes any bind status error messages that were previously stored under `this key` in the `PageContext.PAGE_SCOPE`.

  Overrides:
    `removeAttributes` in class `AbstractHtmlElementBodyTag`
  See Also:
    `exposeAttributes()`