44. spring-form JSP Tag Library

44.1 Introduction

One of the view technologies you can use with the Spring Framework is Java Server Pages (JSPs). To help you implement views using Java Server Pages the Spring Framework provides you with some tags for evaluating errors, setting themes and outputting internationalized messages.

Please note that the various tags generated by this form tag library are compliant with the XHTML-1.0-Strict specification and attendant DTD.

This appendix describes the spring-form.tld tag library.

44.2 The button tag

Renders a form field label in an HTML 'button' tag.

Table 44.1. Attributes

AttributeRequired?Runtime Expression?Description
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
idfalsetrueHTML Standard Attribute
namefalsetrueThe name attribute for the HTML button tag
valuefalsetrueThe name attribute for the HTML button tag

44.3 The checkbox tag

Renders an HTML 'input' tag with type 'checkbox'.

Table 44.2. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
labelfalsetrueValue to be displayed as part of the tag
langfalsetrueHTML Standard Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute
valuefalsetrueHTML Optional Attribute

44.4 The checkboxes tag

Renders multiple HTML 'input' tags with type 'checkbox'.

Table 44.3. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
delimiterfalsetrueDelimiter to use between each 'input' tag with type 'checkbox'. There is no delimiter by default.
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
elementfalsetrueSpecifies the HTML element that is used to enclose each 'input' tag with type 'checkbox'. Defaults to 'span'.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
itemLabelfalsetrueValue to be displayed as part of the 'input' tags with type 'checkbox'
itemstruetrueThe Collection, Map or array of objects used to generate the 'input' tags with type 'checkbox'
itemValuefalsetrueName of the property mapped to 'value' attribute of the 'input' tags with type 'checkbox'
langfalsetrueHTML Standard Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.5 The errors tag

Renders field errors in an HTML 'span' tag.

Table 44.4. Attributes

AttributeRequired?Runtime Expression?Description
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
delimiterfalsetrueDelimiter for displaying multiple error messages. Defaults to the br tag.
dirfalsetrueHTML Standard Attribute
elementfalsetrueSpecifies the HTML element that is used to render the enclosing errors.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
langfalsetrueHTML Standard Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
pathfalsetruePath to errors object for data binding
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.6 The form tag

Renders an HTML 'form' tag and exposes a binding path to inner tags for binding.

Table 44.5. Attributes

AttributeRequired?Runtime Expression?Description
acceptCharsetfalsetrueSpecifies 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.
actionfalsetrueHTML Required Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
enctypefalsetrueHTML Optional Attribute
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
langfalsetrueHTML Standard Attribute
methodfalsetrueHTML Optional Attribute
methodParamfalsetrueThe parameter name used for HTTP methods other then GET and POST. Default is '_method'.
modelAttributefalsetrueName of the model attribute under which the form object is exposed. Defaults to 'command'.
namefalsetrueHTML Standard Attribute - added for backwards compatibility cases
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
onresetfalsetrueHTML Event Attribute
onsubmitfalsetrueHTML Event Attribute
servletRelativeActionfalsetrueAction reference to be appended to the current servlet path
targetfalsetrueHTML Optional Attribute
titlefalsetrueHTML Standard Attribute

44.7 The hidden tag

Renders an HTML 'input' tag with type 'hidden' using the bound value.

Table 44.6. Attributes

AttributeRequired?Runtime Expression?Description
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
pathtruetruePath to property for data binding

44.8 The input tag

Renders an HTML 'input' tag with type 'text' using the bound value.

Table 44.7. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
altfalsetrueHTML Optional Attribute
autocompletefalsetrueCommon Optional Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
langfalsetrueHTML Standard Attribute
maxlengthfalsetrueHTML Optional Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
onselectfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
readonlyfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will make the HTML element readonly.
sizefalsetrueHTML Optional Attribute
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.9 The label tag

Renders a form field label in an HTML 'label' tag.

Table 44.8. Attributes

AttributeRequired?Runtime Expression?Description
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute.
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used only when errors are present.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
forfalsetrueHTML Standard Attribute
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
langfalsetrueHTML Standard Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
pathtruetruePath to errors object for data binding
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.10 The option tag

Renders a single HTML 'option'. Sets 'selected' as appropriate based on bound value.

Table 44.9. Attributes

AttributeRequired?Runtime Expression?Description
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
labelfalsetrueHTML Optional Attribute
langfalsetrueHTML Standard Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute
valuetruetrueHTML Optional Attribute

44.11 The options tag

Renders a list of HTML 'option' tags. Sets 'selected' as appropriate based on bound value.

Table 44.10. Attributes

AttributeRequired?Runtime Expression?Description
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
itemLabelfalsetrueName of the property mapped to the inner text of the 'option' tag
itemstruetrueThe Collection, Map or array of objects used to generate the inner 'option' tags
itemValuefalsetrueName of the property mapped to 'value' attribute of the 'option' tag
langfalsetrueHTML Standard Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.12 The password tag

Renders an HTML 'input' tag with type 'password' using the bound value.

Table 44.11. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
altfalsetrueHTML Optional Attribute
autocompletefalsetrueCommon Optional Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
langfalsetrueHTML Standard Attribute
maxlengthfalsetrueHTML Optional Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
onselectfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
readonlyfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will make the HTML element readonly.
showPasswordfalsetrueIs the password value to be shown? Defaults to false.
sizefalsetrueHTML Optional Attribute
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.13 The radiobutton tag

Renders an HTML 'input' tag with type 'radio'.

Table 44.12. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
labelfalsetrueValue to be displayed as part of the tag
langfalsetrueHTML Standard Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute
valuefalsetrueHTML Optional Attribute

44.14 The radiobuttons tag

Renders multiple HTML 'input' tags with type 'radio'.

Table 44.13. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
delimiterfalsetrueDelimiter to use between each 'input' tag with type 'radio'. There is no delimiter by default.
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
elementfalsetrueSpecifies the HTML element that is used to enclose each 'input' tag with type 'radio'. Defaults to 'span'.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
itemLabelfalsetrueValue to be displayed as part of the 'input' tags with type 'radio'
itemstruetrueThe Collection, Map or array of objects used to generate the 'input' tags with type 'radio'
itemValuefalsetrueName of the property mapped to 'value' attribute of the 'input' tags with type 'radio'
langfalsetrueHTML Standard Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.15 The select tag

Renders an HTML 'select' element. Supports databinding to the selected option.

Table 44.14. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
itemLabelfalsetrueName of the property mapped to the inner text of the 'option' tag
itemsfalsetrueThe Collection, Map or array of objects used to generate the inner 'option' tags
itemValuefalsetrueName of the property mapped to 'value' attribute of the 'option' tag
langfalsetrueHTML Standard Attribute
multiplefalsetrueHTML Optional Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
sizefalsetrueHTML Optional Attribute
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute

44.16 The textarea tag

Renders an HTML 'textarea'.

Table 44.15. Attributes

AttributeRequired?Runtime Expression?Description
accesskeyfalsetrueHTML Standard Attribute
colsfalsetrueHTML Required Attribute
cssClassfalsetrueEquivalent to "class" - HTML Optional Attribute
cssErrorClassfalsetrueEquivalent to "class" - HTML Optional Attribute. Used when the bound field has errors.
cssStylefalsetrueEquivalent to "style" - HTML Optional Attribute
dirfalsetrueHTML Standard Attribute
disabledfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will disable the HTML element.
htmlEscapefalsetrueEnable/disable HTML escaping of rendered values.
idfalsetrueHTML Standard Attribute
langfalsetrueHTML Standard Attribute
onblurfalsetrueHTML Event Attribute
onchangefalsetrueHTML Event Attribute
onclickfalsetrueHTML Event Attribute
ondblclickfalsetrueHTML Event Attribute
onfocusfalsetrueHTML Event Attribute
onkeydownfalsetrueHTML Event Attribute
onkeypressfalsetrueHTML Event Attribute
onkeyupfalsetrueHTML Event Attribute
onmousedownfalsetrueHTML Event Attribute
onmousemovefalsetrueHTML Event Attribute
onmouseoutfalsetrueHTML Event Attribute
onmouseoverfalsetrueHTML Event Attribute
onmouseupfalsetrueHTML Event Attribute
onselectfalsetrueHTML Event Attribute
pathtruetruePath to property for data binding
readonlyfalsetrueHTML Optional Attribute. Setting the value of this attribute to 'true' will make the HTML element readonly.
rowsfalsetrueHTML Required Attribute
tabindexfalsetrueHTML Standard Attribute
titlefalsetrueHTML Standard Attribute
Updated at: 7 months ago
43.13. The url tagTable of content