类 ErrorsTag
- java.lang.Object
- 所有已实现的接口:
Serializable
,BodyTag
,DynamicAttributes
,IterationTag
,JspTag
,Tag
,TryCatchFinally
,EditorAwareTag
public class ErrorsTag extends AbstractHtmlElementBodyTag implements BodyTag
The<errors>
tag renders field errors in an HTML 'span' tag. Displays errors for either an object or a particular field.This tag supports three main usage patterns:
- Field only - set '
path
' to the field name (or path) - Object errors only - omit '
path
' - All errors - set '
path
' to '*
'
Attribute Summary Attribute Required? Runtime Expression? Description cssClass
false
true
HTML Optional Attribute
cssStyle
false
true
HTML Optional Attribute
delimiter
false
true
Delimiter for displaying multiple error messages. Defaults to the br tag.
dir
false
true
HTML Standard Attribute
element
false
true
Specifies the HTML element that is used to render the enclosing errors.
htmlEscape
false
true
Enable/disable HTML escaping of rendered values.
id
false
true
HTML Standard Attribute
lang
false
true
HTML Standard Attribute
onclick
false
true
HTML Event Attribute
ondblclick
false
true
HTML Event Attribute
onkeydown
false
true
HTML Event Attribute
onkeypress
false
true
HTML Event Attribute
onkeyup
false
true
HTML Event Attribute
onmousedown
false
true
HTML Event Attribute
onmousemove
false
true
HTML Event Attribute
onmouseout
false
true
HTML Event Attribute
onmouseover
false
true
HTML Event Attribute
onmouseup
false
true
HTML Event Attribute
path
false
true
Path to errors object for data binding
tabindex
false
true
HTML Standard Attribute
title
false
true
HTML Standard Attribute
- 从以下版本开始:
- 2.0
- 作者:
- Rob Harrop, Juergen Hoeller, Rick Evans
- 另请参阅:
- 序列化表格
字段概要
字段 修饰符和类型 字段 说明 static String
MESSAGES_ATTRIBUTE
The key under which this tag exposes error messages in thepage context scope
.static String
SPAN_TAG
The HTML 'span
' tag.从类继承的字段 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
从类继承的字段 org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
NESTED_PATH_VARIABLE_NAME
从类继承的字段 org.springframework.web.servlet.tags.RequestContextAwareTag
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE
从类继承的字段 javax.servlet.jsp.tagext.TagSupport
pageContext
从接口继承的字段 javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
从接口继承的字段 javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
从接口继承的字段 javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
构造器概要
构造器 构造器 说明 ErrorsTag()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected String
autogenerateId()
Get the value for the HTML 'id
' attribute.protected void
exposeAttributes()
Exposes any bind status error messages underthis key
in thePageContext.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 underthis key
in thePageContext.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?从类继承的方法 org.springframework.web.servlet.tags.form.AbstractHtmlElementBodyTag
doEndTag, doFinally, doInitBody, flushBufferedBodyContent, onWriteTagContent, renderFromBodyContent, setBodyContent, writeTagContent
从类继承的方法 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
从类继承的方法 org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag
convertToDisplayString, getBindStatus, getBoundValue, getEditor, getId, getNestedPath, getPath, getPropertyEditor, getPropertyPath, processFieldValue, resolveId, setId, setPath
从类继承的方法 org.springframework.web.servlet.tags.form.AbstractFormTag
createTagWriter, doStartTagInternal, evaluate, getDisplayString, getDisplayString, isDefaultHtmlEscape, writeOptionalAttribute
从类继承的方法 org.springframework.web.servlet.tags.HtmlEscapingAwareTag
htmlEscape, isHtmlEscape, isResponseEncodedHtmlEscape, setHtmlEscape
从类继承的方法 org.springframework.web.servlet.tags.RequestContextAwareTag
doCatch, doStartTag, getRequestContext
从类继承的方法 javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getParent, getValue, getValues, release, removeValue, setPageContext, setParent, setValue
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 javax.servlet.jsp.tagext.BodyTag
doInitBody, setBodyContent
从接口继承的方法 javax.servlet.jsp.tagext.IterationTag
doAfterBody
从接口继承的方法 javax.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
字段详细资料
MESSAGES_ATTRIBUTE
public static final String MESSAGES_ATTRIBUTE
The key under which this tag exposes error messages in thepage context scope
.- 另请参阅:
- 常量字段值
构造器详细资料
ErrorsTag
public ErrorsTag()
方法详细资料
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 byAbstractDataBoundFormElementTag.getPropertyPath()
or to the model attribute name if the<form:errors/>
tag's 'path
' attribute has been omitted.- 覆盖:
autogenerateId
在类中AbstractDataBoundFormElementTag
- 返回:
- the value for the HTML '
id
' attribute - 抛出:
JspException
- 另请参阅:
AbstractDataBoundFormElementTag.getPropertyPath()
getName
@Nullable 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.- 覆盖:
getName
在类中AbstractDataBoundFormElementTag
- 返回:
- the value for the HTML '
name
' attribute - 抛出:
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
.- 覆盖:
shouldRender
在类中AbstractHtmlElementBodyTag
- 返回:
true
only when there are errors for the configuredpath
- 抛出:
JspException
renderDefaultContent
protected void renderDefaultContent(TagWriter tagWriter) throws JspException
exposeAttributes
protected void exposeAttributes() throws JspException
Exposes any bind status error messages underthis key
in thePageContext.PAGE_SCOPE
.Only called if
shouldRender()
returnstrue
.
removeAttributes
protected void removeAttributes()
Removes any bind status error messages that were previously stored underthis key
in thePageContext.PAGE_SCOPE
.