2
所以,我的场景如下。Struts2 - 验证和瓷砖参数
- 页面显示文章的呼叫newInfo.action与条款ArticleID参数
- 形式的行动将调用postComment.action
- postComment.action将调用的validate()
- 的validate()返回验证错误。
- *问题是在这里,我如何返回到瓷砖并获取验证错误?
我在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.");
}
目前,该页面产生的文章页面,为 “现场错误”,但页面犯规显示任何领域的错误。 那么,有没有解决方案来解决它?