【发布时间】:2011-03-22 19:24:13
【问题描述】:
所以,我的场景在下面。
- 页面通过调用 newInfo.action 和 articleId 参数显示文章
- 表单操作将调用 postComment.action
- postComment.action 将调用 validate()
- validate() 返回验证错误。
- * 问题就在这里,我如何返回到 tile 并得到验证错误?
我的 struts.xml
<action name="newInfo" class="org.blog.controller.NewInfo">
<result type="tiles" name="success">NewInfo</result>
</action>
<action name="postComment" class="org.blog.controller.CommentController">
<result type="redirectAction" name="success">newInfo?id=${articleId}</result
<result type="redirect" name="input">newInfo.action?id=${articleId}</result>
</action>
CommentController.java
public void validate() {
if(getName().length() == 0)
addFieldError("name", "Name is required");
if(getEmail().length() == 0)
addFieldError("email", "Email is required");
if(getCurrentURL().length() == 0)
addFieldError("website", "Website is required");
if(hasFieldErrors())
System.out.println("Field error.");
}
当前,页面结果是文章页面,有“字段错误”,但页面没有显示任何字段错误。 那么,有什么解决方案可以解决吗?
【问题讨论】:
标签: validation struts2 tiles