您必须导入spring形式taglib才能使用spring形式的elemnet:
将此添加到您的jsp顶部
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
然后,您可以像这样使用:
<form:form id="myForm" method="post" action="/someAction" modelAttribute="formBean"> <form:label path="name"/> <form:input path="name"/><form:form>
并且您在控制器中添加了modelAttribute / command对象,例如:
@RequestMapping(value="/someUrl", method=RequestMethod.GET)public String showForm(Model model){ model.addAttribute("formBean", new FormBean()); return "someViewName";}和
FormBean类看起来像:
public class FormBean { private String name; public FormBean(){} //default constructor //getter and setter for name}


