<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <html> <head> <title>表单标签</title> </head> <body> <!-- 使用form:form来生成HTML的form标签,主要作用是便于我们实现表单回显 --> <!-- modelAttribute属性:会从请求域中读取和属性名对应的属性,如果没有获取到对应的对象会抛出异常 --> <!-- java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'employee' available as request attribute --> <!-- 说明SpringMVC在底层会调用request.setAttribute("employee") --> <form:formaction=""method="post"modelAttribute="employee"> <!-- 在具体表单标签中,访问模型对象的属性时,如果属性名不匹配,会抛出下面异常: --> <!-- org.springframework.beans.NotReadablePropertyException: Invalid property 'empName' of bean class [java.lang.Object]: Bean property 'empName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? --> <!-- 说明SpringMVC底层会根据这里指定的名称作为属性名访问实体类对象(属性名和getXxx()、setXxx()方法按照默认规则对应) --> <!-- form:input标签:生成普通文本框,path属性生成文本框的name属性,SpringMVC负责实现表单回显 --> 员工姓名:<form:inputpath="empName" /><br />