类 FormTag
- 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.FormTag
- 所有已实现的接口:
Serializable
,DynamicAttributes
,IterationTag
,JspTag
,Tag
,TryCatchFinally
,EditorAwareTag
public class FormTag extends AbstractHtmlElementTag
The<form>
tag renders an HTML 'form' tag and exposes a binding path to inner tags for binding.Users should place the form object into the
ModelAndView
when populating the data for their view. The name of this form object can be configured using the"modelAttribute"
property.Attribute Summary Attribute Required? Runtime Expression? Description acceptCharset
false
true
Specifies the list of character encodings for input data that is accepted by the server processing this form. The value is a space- and/or comma-delimited list of charset values. The client must interpret this list as an exclusive-or list, i.e., the server is able to accept any single character encoding per entity received.
action
false
true
HTML Required Attribute
cssClass
false
true
HTML Optional Attribute
cssStyle
false
true
HTML Optional Attribute
dir
false
true
HTML Standard Attribute
enctype
false
true
HTML Optional Attribute
htmlEscape
false
true
Enable/disable HTML escaping of rendered values.
id
false
true
HTML Standard Attribute
lang
false
true
HTML Standard Attribute
method
false
true
HTML Optional Attribute
methodParam
false
true
The parameter name used for HTTP methods other then GET and POST. Default is '_method'.
modelAttribute
false
true
Name of the model attribute under which the form object is exposed. Defaults to 'command'.
name
false
true
HTML Standard Attribute - added for backwards compatibility cases
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
onreset
false
true
HTML Event Attribute
onsubmit
false
true
HTML Event Attribute
servletRelativeAction
false
true
Action reference to be appended to the current servlet path
target
false
true
HTML Optional Attribute
title
false
true
HTML Standard Attribute
- 从以下版本开始:
- 2.0
- 作者:
- Rob Harrop, Juergen Hoeller, Scott Andrews, Rossen Stoyanchev
- 另请参阅:
- 序列化表格
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_COMMAND_NAME
The default attribute name: "command".static String
MODEL_ATTRIBUTE_VARIABLE_NAME
The name of thePageContext
attribute under which the form object name is exposed.从类继承的字段 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.IterationTag
EVAL_BODY_AGAIN
从接口继承的字段 javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
构造器概要
构造器 构造器 说明 FormTag()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected String
autogenerateId()
Autogenerated IDs correspond to the form object name.int
doEndTag()
Closes the 'form
' block tag and removes the form object name from thePageContext
.void
doFinally()
Clears the storedTagWriter
.protected String
getAcceptCharset()
Get the value of the 'acceptCharset
' attribute.protected String
getAction()
Get the value of the 'action
' attribute.protected String
getAutocomplete()
Get the value of the 'autocomplete
' attribute.protected String
getEnctype()
Get the value of the 'enctype
' attribute.protected String
getMethod()
Get the value of the 'method
' attribute.protected String
getMethodParam()
Get the name of the request param for non-browser supported HTTP methods.protected String
getModelAttribute()
Get the name of the form attribute in the model.protected String
getName()
Get the value of the 'name
' attribute.protected String
getOnreset()
Get the value of the 'onreset
' attribute.protected String
getOnsubmit()
Get the value of the 'onsubmit
' attribute.protected String
getServletRelativeAction()
Get the servlet-relative value of the 'action
' attribute.String
getTarget()
Get the value of the 'target
' attribute.protected boolean
isMethodBrowserSupported(String method)
Determine if the HTTP method is supported by browsers (i.e.protected String
resolveAction()
Resolve the value of the 'action
' attribute.protected String
resolveCssClass()
Override resolve CSS class since error class is not supported.protected String
resolveModelAttribute()
Resolves
and returns the name of the form object.void
setAcceptCharset(String acceptCharset)
Set the value of the 'acceptCharset
' attribute.void
setAction(String action)
Set the value of the 'action
' attribute.void
setAutocomplete(String autocomplete)
Set the value of the 'autocomplete
' attribute.void
setCssErrorClass(String cssErrorClass)
Unsupported for forms.void
setEnctype(String enctype)
Set the value of the 'enctype
' attribute.void
setMethod(String method)
Set the value of the 'method
' attribute.void
setMethodParam(String methodParam)
Set the name of the request param for non-browser supported HTTP methods.void
setModelAttribute(String modelAttribute)
Set the name of the form attribute in the model.void
setName(String name)
Set the value of the 'name
' attribute.void
setOnreset(String onreset)
Set the value of the 'onreset
' attribute.void
setOnsubmit(String onsubmit)
Set the value of the 'onsubmit
' attribute.void
setPath(String path)
Unsupported for forms.void
setServletRelativeAction(String servletRelativeAction)
Set the value of the 'action
' attribute through a value that is to be appended to the current servlet path.void
setTarget(String target)
Set the value of the 'target
' attribute.protected int
writeTagContent(TagWriter tagWriter)
Writes the opening part of the block 'form
' tag and exposes the form object name in thePageContext
.从类继承的方法 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, setCssClass, 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
从类继承的方法 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
字段详细资料
DEFAULT_COMMAND_NAME
public static final String DEFAULT_COMMAND_NAME
The default attribute name: "command".- 另请参阅:
- 常量字段值
MODEL_ATTRIBUTE_VARIABLE_NAME
public static final String MODEL_ATTRIBUTE_VARIABLE_NAME
The name of thePageContext
attribute under which the form object name is exposed.
构造器详细资料
FormTag
public FormTag()
方法详细资料
setModelAttribute
public void setModelAttribute(String modelAttribute)
Set the name of the form attribute in the model.May be a runtime expression.
getModelAttribute
protected String getModelAttribute()
Get the name of the form attribute in the model.
setName
public void setName(String name)
Set the value of the 'name
' attribute.May be a runtime expression.
Name is not a valid attribute for form on XHTML 1.0. However, it is sometimes needed for backward compatibility.
getName
@Nullable protected String getName() throws JspException
Get the value of the 'name
' attribute.- 覆盖:
getName
在类中AbstractDataBoundFormElementTag
- 返回:
- the value for the HTML '
name
' attribute - 抛出:
JspException
setAction
public void setAction(@Nullable String action)
Set the value of the 'action
' attribute.May be a runtime expression.
setServletRelativeAction
public void setServletRelativeAction(@Nullable String servletRelativeAction)
Set the value of the 'action
' attribute through a value that is to be appended to the current servlet path.May be a runtime expression.
- 从以下版本开始:
- 3.2.3
getServletRelativeAction
@Nullable protected String getServletRelativeAction()
Get the servlet-relative value of the 'action
' attribute.- 从以下版本开始:
- 3.2.3
setMethod
public void setMethod(String method)
Set the value of the 'method
' attribute.May be a runtime expression.
setTarget
public void setTarget(String target)
Set the value of the 'target
' attribute.May be a runtime expression.
setEnctype
public void setEnctype(String enctype)
Set the value of the 'enctype
' attribute.May be a runtime expression.
getEnctype
@Nullable protected String getEnctype()
Get the value of the 'enctype
' attribute.
setAcceptCharset
public void setAcceptCharset(String acceptCharset)
Set the value of the 'acceptCharset
' attribute.May be a runtime expression.
getAcceptCharset
@Nullable protected String getAcceptCharset()
Get the value of the 'acceptCharset
' attribute.
setOnsubmit
public void setOnsubmit(String onsubmit)
Set the value of the 'onsubmit
' attribute.May be a runtime expression.
getOnsubmit
@Nullable protected String getOnsubmit()
Get the value of the 'onsubmit
' attribute.
setOnreset
public void setOnreset(String onreset)
Set the value of the 'onreset
' attribute.May be a runtime expression.
getOnreset
@Nullable protected String getOnreset()
Get the value of the 'onreset
' attribute.
setAutocomplete
public void setAutocomplete(String autocomplete)
Set the value of the 'autocomplete
' attribute. May be a runtime expression.
getAutocomplete
@Nullable protected String getAutocomplete()
Get the value of the 'autocomplete
' attribute.
setMethodParam
public void setMethodParam(String methodParam)
Set the name of the request param for non-browser supported HTTP methods.
getMethodParam
protected String getMethodParam()
Get the name of the request param for non-browser supported HTTP methods.- 从以下版本开始:
- 4.2.3
isMethodBrowserSupported
protected boolean isMethodBrowserSupported(String method)
Determine if the HTTP method is supported by browsers (i.e. GET or POST).
writeTagContent
protected int writeTagContent(TagWriter tagWriter) throws JspException
Writes the opening part of the block 'form
' tag and exposes the form object name in thePageContext
.- 指定者:
writeTagContent
在类中AbstractFormTag
- 参数:
tagWriter
- theTagWriter
to which the form content is to be written- 返回:
Tag.EVAL_BODY_INCLUDE
- 抛出:
JspException
autogenerateId
protected String autogenerateId() throws JspException
Autogenerated IDs correspond to the form object name.
resolveModelAttribute
protected String resolveModelAttribute() throws JspException
Resolves
and returns the name of the form object.- 抛出:
IllegalArgumentException
- if the form object resolves tonull
JspException
resolveAction
protected String resolveAction() throws JspException
Resolve the value of the 'action
' attribute.If the user configured an '
action
' value then the result of evaluating this value is used. If the user configured an 'servletRelativeAction
' value then the value is prepended with the context and servlet paths, and the result is used. Otherwise, theoriginating URI
is used.- 返回:
- the value that is to be used for the '
action
' attribute - 抛出:
JspException
doEndTag
public int doEndTag() throws JspException
Closes the 'form
' block tag and removes the form object name from thePageContext
.- 指定者:
doEndTag
在接口中Tag
- 覆盖:
doEndTag
在类中TagSupport
- 抛出:
JspException
doFinally
public void doFinally()
Clears the storedTagWriter
.- 指定者:
doFinally
在接口中TryCatchFinally
- 覆盖:
doFinally
在类中AbstractDataBoundFormElementTag
resolveCssClass
protected String resolveCssClass() throws JspException
Override resolve CSS class since error class is not supported.
setPath
public void setPath(String path)
Unsupported for forms.- 覆盖:
setPath
在类中AbstractDataBoundFormElementTag
- 抛出:
UnsupportedOperationException
- always
setCssErrorClass
public void setCssErrorClass(String cssErrorClass)
Unsupported for forms.- 覆盖:
setCssErrorClass
在类中AbstractHtmlElementTag
- 抛出:
UnsupportedOperationException
- always