freemarker中spring表单错误信息显示

 

http://hi.baidu.com/danghj/blog/item/e567b5340e1677add0a2d3b6.html

 

只是为了记录,避免忘记

 

<form action="regDo.do" method="POST">

<table style="width: 100%; height: 100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<th>邮箱</th>

<td><input name="termId" type="text" class="text-input" /></td>

<td><form:errors path="term.termId"></form:errors></td>

</tr>

<tr>

<th>密码</th>

<td><input id="termName" name="termName" type="text" class="text-input" /></td>

<td><form:errors path="term.termName"></form:errors></td>

</tr>

<tr>

<td>&nbsp;</td>

 

<td><input type="submit" name="btn_tijiao" value="提交注册" /></td>

</tr>

</table>

</form>

 

<form:form action="regDo.do" method="POST" commandName="term">

<table style="width: 100%; height: 100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<th>邮箱</th>

<td><input name="termId" type="text" class="text-input" /></td>

<td><form:errors path="termId"></form:errors></td>

</tr>

<tr>

<th>密码</th>

<td><input id="termName" name="termName" type="text" class="text-input" /></td>

<td><form:errors path="termName"></form:errors></td>

</tr>

<tr>

<td>&nbsp;</td>

 

<td><input type="submit" name="btn_tijiao" value="提交注册" /></td>

</tr>

</table>

</form:form>

 

同时:

@ModelAttribute("term") Terms term, BindingResult result

 

 

 

在freemarker中

 

 

<form action="regDo.do" method="POST">

<table style="width: 100%; height: 100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<th>termId---</th>

<td>

[@spring.formInput "term.termId" /]

</td>

<td>[@spring.showErrors "" /]</td>

</tr>

<tr>

<th></th>

<td>

</td>

<td>[@spring.showErrors "" /]</td>

</tr>

<tr>

<th>taxonomy</th>

<td>

[@spring.formInput "term.taxonomy" /]

</td>

<td></td>

</tr>

<tr>

<th>termName</th>

<td>

[@spring.formInput "term.termName" /]

</td>

<td>[@spring.showErrors "" /]</td>

</tr>

<tr>

<th></th>

<td>

</td>

<td>[@spring.showErrors "" /]</td>

</tr>

<tr>

<td>&nbsp;</td>

 

<td><input type="submit" name="btn_tijiao" value="提交注册" /></td>

</tr>

</table>

</form>

 

那么:

 

原来他是先根据
[@spring.formInput "term.termId" /]
然后才能输出
[@spring.showErrors "" /]
只要不再调用下一个[@spring.formInput
那么即使多次调用[@spring.showErrors "" /]
显示的信息依旧是上一个的

但是开始时候不能先
<td>[@spring.showErrors "" /]</td>
[@spring.formInput "term.termId" /]

你可能感兴趣的:(spring,freemarker,Class,action,Path,border)