Use form tags to develop form pages more quickly and to make it easier to echo form values
Attention:
You can specify the model properties of a binding by using the Modelattribute property.
If this property is not specified, the default form bean that reads command from the request domain object
If the property value also does not exist, an error occurs.
Instance
<%@ taglib prefix= "form" uri= "Http://www.springframework.org/tags/form"%>
<%@ taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core"%>
<form:form action= "${pagecontext.request.contextpath}/emp" method= "POST"
Modelattribute= "Employee" >
<form:errors path= "*" ></form:errors>
<br>
<c:if test= "${employee.id = = null}" >
<!--the Path property corresponds to the Name property value of the HTML form label--
LastName: <form:input path= "LastName"/>
<form:errors path= "LastName" ></form:errors>
</c:if>
<c:if test= "${employee.id! = null}" >
<form:hidden path= "id"/>
<input type= "hidden" name= "_method" value= "PUT"/>
<%--cannot use the Form:hidden tag for _method because Modelattribute does not have _method in the corresponding bean--%>
<%--
<form:hidden path= "_method" value= "PUT"/>
--%>
</c:if>
<br>
Email: <form:input path= "Email"/>
<form:errors path= "Email" ></form:errors>
<br>
<%
map<string, string> genders = new HashMap ();
Genders.put ("1", "Male");
Genders.put ("0", "Female");
Request.setattribute ("genders", genders);
%>
Gender:
<br>
<form:radiobuttons path= "Gender" items= "${genders}" delimiter= "<br>"/>
<br>
Department: <form:select path= "Department.id"
items= "${departments}" itemlabel= "Departmentname" itemvalue= "id" ></form:select>
<br>
Birth: <form:input path= "Birth"/>
<form:errors path= "Birth" ></form:errors>
<br>
Salary: <form:input path= "Salary"/>
<br>
<input type= "Submit" value= "Submit"/>
</form:form>
SPRINGMVC Form Label