Struts忽略验证方法

发布于 2024-12-18 17:02:59 字数 882 浏览 2 评论 0原文

<form-bean name="RegisterForm" type="com.mysite.form.RegisterForm" />

<action path="/register" type="com.mysite.action.RegisterAction" name="RegisterForm" input="/register.jsp" validate="true">
                <forward name="success" path="/welcome.jsp" />
                <forward name="failure" path="/register.jsp" />
            </action>

RegisterForm

public class RegisterForm extends ActionForm{
private String name;

    /**
    Constructor
    Set+Get
    **/

    public ActionErrors validate(ActionMapping mapping, ServletRequest request) {

        ActionErrors errorList = new ActionErrors();
        System.out.println("VALIDATING");
        return errorList;
    }
}

这就是我所拥有的一切。由于某种原因,控制流似乎直接跳转到 ActionForm 的执行方法,因为我什至在控制台中看不到 VALIDATING 消息。我有什么遗漏的吗?谢谢!

<form-bean name="RegisterForm" type="com.mysite.form.RegisterForm" />

<action path="/register" type="com.mysite.action.RegisterAction" name="RegisterForm" input="/register.jsp" validate="true">
                <forward name="success" path="/welcome.jsp" />
                <forward name="failure" path="/register.jsp" />
            </action>

RegisterForm

public class RegisterForm extends ActionForm{
private String name;

    /**
    Constructor
    Set+Get
    **/

    public ActionErrors validate(ActionMapping mapping, ServletRequest request) {

        ActionErrors errorList = new ActionErrors();
        System.out.println("VALIDATING");
        return errorList;
    }
}

This is all i have. For some reason it seems that the control flow jumps directly to the ActionForm's execute method because I can't even see the VALIDATING message in the console. Is there something I'm missing? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素年丶 2024-12-25 17:03:00

您需要使用另一个采用 HttpServletRequest 的重载 validate() 方法

You need to use the other overloaded validate() method that takes HttpServletRequest

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文