Spring and Spring form tag libraries

Spring bundles a set of tags for the easier authoring of plain JSP pages and JSP forms, defined in spring.tld and spring-form.tld respectively. spring.tld describes general-purpose JSP tags commonly used in JSP pages, listed in the following table:

Spring tag

Description

<spring:bind/>

This allows the data binding of an attribute given in the bind path of a locally declared bean or a Model attribute and provides a BindStatus object to the enclosed body content.

<spring:escapeBody/>

This applies HTML escaping and JavaScript escaping for the body.

<spring:hasBindErrors/>

This provides an error instance if there are bind errors.

<spring:htmlEscape/>

This sets an HTML escape value for the current JSP page.

<spring:message/>

This displays a message for a given code, usually resolved from a resource bundle.

<spring:nestedPath/>

This sets a nested path of ModelAttribute to the <spring:bind/> tags enclosed inside.

<spring:theme/>

This loads the theme resource using the given code.

<spring:transform/>

This transforms properties inside the <spring:bind/> tag and exports them to a variable in a given scope.

<spring:url/>

This creates a URL with URI template variables. It is modeled after the JSTL c:url tag.

<spring:eval/>

This evaluates SpEL expressions.

Spring form tags provide data binding for HTML forms. They have tight integration with request handlers in controllers. Generally, they represent similarly named HTML form elements and share common attributes:

Form tag

Sample

<form:input/>

<form:input path="name" placeholder="Task Name"/>

<form:textarea/>

<form:textarea path="comments" id="txtComments" rows="5" cols="30" />

<form:select/>

<form:option/> and

<form:options/>

<form:select path="createdBy" id="selectCreatedBy">

<form:option value="-1" label="Select"/>

<form:options items="${users}" itemValue="id" itemLabel="name" />

</form:select>

<form:label/>

<form:label for="txtTaskName" path="name">Task-names</form:label>

<form:hidden/>>

<form:hidden path="taskId" id="hdnTaskId"/>

<form:password/>

<form:password path="userPassword"/>

<form:radiobutton/>

<form:radiobutton path="sex" value="Male"/>

<form:radiobuttons/>

<form:radiobuttons path="sex" items="${sexOptions}"/>

<form:checkbox/>

<form:checkbox path="task.priority" value="1"/>

<form:checkboxes/>

<form:checkboxes path="task.priority" value="${taskPriorities}"/>

<form:password/>

<form:password path="password" />

<form:errors/>

<form:errors path="createdBy.id" />

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset