【问题标题】:struts 1 validationstruts 1 验证
【发布时间】:2012-02-11 16:22:49
【问题描述】:

大家好,我在使用 struts 验证时遇到问题,如下所示: 已加载编辑配置文件页面,当用户单击保存时,应执行验证,如果存在错误,则必须重定向到同一页面,并显示验证错误并加载数据,否则调用执行方法。错误列表有值但屏幕上没有显示错误会发生什么情况,我的代码快照是: 我正在使用 struts 1

<action path="/selectUserAction" validate="true" input="/selectUserAction.do"       type="com.bg.sharjah.usermanagement.manageusersgroups.web.actions.SelectUserAction" 
        name="editUserProfileFormBean" scope="request">


    @Override
public ActionErrors validate(ActionMapping mapping,
        HttpServletRequest request) {
    //Logger.getAnonymousLogger().log(Level.WARNING,"");
    ActionErrors errors = new ActionErrors();
    try{

    errors = super.validate(mapping, request);
    System.out.println("validate <<<<<<<<<<< "+errors.size());

    }catch(Exception e)
    {
        e.printStackTrace();
    }
    return errors;
//  Validation.match(errors, password, confirmPassword);
    //Validation.match(errors, email, confirmEmail);    

}

注意: 我的表单 bean 用于不同的操作,我还需要知道如何使用输入属性重定向到同一页面?

【问题讨论】:

  • 如何显示错误?
  • 你是手动调用validate,还是框架调用它?
  • 如果你手动调用它,你需要调用saveErrors
  • 我只是重写了方法,这是否意味着我手动调用它?
  • 不,叫它就是叫它。

标签: struts-1 struts-validation


【解决方案1】:

谢谢,我发现问题是资源包问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多