Validation Struts2-验证和测试;平铺参数

Validation Struts2-验证和测试;平铺参数,validation,struts2,tiles,Validation,Struts2,Tiles,下面是我的场景 页面通过调用newInfo.action和articleId参数显示文章 表单操作将调用postComment.action postComment.action将调用validate() validate()返回验证错误 *问题是,我如何返回到tile并获得验证错误 我的struts.xml <action name="newInfo" class="org.blog.controller.NewInfo"> <result type="tiles"

下面是我的场景

  • 页面通过调用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>
    
    当前,页面结果显示文章页面,带有“字段错误”,但页面未显示任何字段错误。 那么,有什么解决办法吗

    将type=“redirect”更改为type=“chain”请参见:了解更多详细信息。

    将type=“redirect”更改为type=“chain”请参见:了解更多详细信息。

    尝试以下操作:

    
    贮藏
    newInfo?id=${articleId}试试这个:

    
    贮藏
    newInfo?id=${articleId}
    
    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.");
    
    }