下面是源码:
<html:form action="employee.do?method=updateEmployee" οnsubmit="return checkEmptyForm(employeeForm)">
<table border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="66583D">
<tr>
<th width="75" height="25">编号:</th>
<td width="200" bgcolor="#FFFFFF"><html:text property="em_serialNumber" readonly="readonly" οnclick="alert('此文本框已设为只读,用户不能修改')"/></td>
<th width="75">姓名:</th>
<td width="200" bgcolor="#FFFFFF"><html:text property="em_name" title="请输入员工姓名"/></td>
</tr>
<html:hidden property="id"/>
<html:submit>修改</html:submit> <html:reset>重置</html:reset> <html:button property="back" value="返回" οnclick="javascript:history.go(-1);"> </html:button>
</html:form>
action=employee对应的Form是EmployeeForm,该<html:form>自动提取文件中EmployeeForm实体类,并利用<html:text>输出相应参数,而不需要手动提取。
在转入该JSP文件的上一个文件中,可以利用下面的代码设置EmployeeForm实体类。
request.setAttribute("employeeForm", employeeForm);
结果employeeForm直接就被<html:form>引用。