English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Spring MVC Form Tags Library

Spring MVC form tags are configurable and reusable building blocks for web pages. These tags provide a simple way for JSP to develop, read, and maintain.

Spring MVC form tags can be considered as tags with data binding awareness, which can automatically set data to a Java object/bean and retrieve it from it. Here, each tag supports a set of properties corresponding to its corresponding HTML tag, making the tag familiar and easy to use.

Spring MVC Form Tags Configuration

The form tag library is located in spring-webmvc.jar. To enable support for the form tag library, you need to refer to some configurations. Therefore, add the following directive at the beginning of the JSP page:

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

List of Spring MVC Form Tags

Let's take a look at some commonly used Spring MVC form tags.

Form TagsDescription
form: form This is a container tag that includes all other form tags.
form: input This tag is used to generate text fields.
form: radioThis tag is used to generate radio buttons.
form:checkboxThis tag is used to generate checkboxes.
form:passwordThis tag is used to generate password input fields.
form: selectThis tag is used to generate drop-down lists.
form: textarea This tag is used to generate multi-line text fields.
form: hidden This tag is used to generate hidden input fields.

Form Tags

Spring MVC form tags are container tags. It is a parent tag that contains all other tags in the tag library. This tag generates HTML form tags and exposes binding paths to internal tags for binding.

Syntax

<form:form action="nextFormPath" modelAttribute=?abc?/>

In the next section, we will delve into each form tag in detail.