Composing a form in JSP

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" ...

Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.