Spring MVC provides tags for handling form elements when using JSP.
Each spring form tag will generate HTML tags at runtime. These tags provide support for the set of attributes of its corresponding HTML tag.
This blog provides a quick reference of how to interpret some of these commonly used spring form tags and understand the attribute level mappings between the Spring form tags and its HTML Counterpart. To use Spring form tags in your JSP, include this library:
<%@ taglib prefix=”form” uri=”http://www.springframework.org/tags/form” %>
The prefix ‘form’ will be used to precede the Spring form tag names. Spring form tags are only valid when contained with the Spring Form tag:
<form:form> … </form:form>
Spring tag |
HTML Tag |
Additional Info |
<form:form> | <form method=”POST”> |
|
<form:input path=”firstName” /> | <input name=”firstName” type=”text” value=”abc”/> |
|
<form:select path=”examples” items=”${examples}”/> | <td><select name=”examples” multiple=”true”> <option value=”example1″>Example 1</option> <option value=”example2″ selected=”selected”>Example 2</option> </select> </td> |
|
<form:hidden path=”hiddenVar” /> | <input name=”hiddenVar” type=”hidden” value=”hiddenVal”/> |
|
References: Spring Form TLD reference:
Spring Framework Web MVC:
Hi Saraswathy, its a good post on Spring topic. I am into software testing side and new to here. Thanks.