Spring forms can be composed in JSP pages using the <spring>
and <form>
tags. For the purpose of illustration, let's take a look at a JSP form that uses both the Spring and form tag libraries along with JSTL. The following is a stripped-down version of views/task/new.jsp
:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> ... <form:form action="new" method="post" commandName="task"> <spring:bind path="name"> <div class="form-group${status.error ? ' has-error' : ''}"> <label for="txtTaskName">Task-name</label> <form:input path="name" class="form-control" id="txtTaskName" placeholder="Task Name" /> <form:errors path="name" cssClass="control-label" /> </div> </spring:bind> <div class="form-group...