【问题标题】:@NotBlank doesn't seem to work@NotBlank 似乎不起作用
【发布时间】:2011-08-09 02:03:16
【问题描述】:

1) 我正在使用 Spring / Hibernate 验证器进行验证,以检查字段是否只有空格或是否保留我在“字符串名称”上使用 @NotBlank (import org.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank;) 注释。但是在添加 @NotBlank 注释后,该字段没有得到验证。

我的控制器类看起来像。

public String addPerson(
      @ModelAttribute("userregistration")@Valid UserRegistration userRegistration ,
      BindingResult result,Model model){
}

2) 进行验证的另一种方法是什么(用于检查唯一的空格),如果用户输入他/她的全名(中间有一个空格),则应该对其进行验证,并且在用户只输入空格?

【问题讨论】:

    标签: forms hibernate spring validation registration


    【解决方案1】:
    • 尝试删除@ModelAttribute注解
    • 检查是否启用了验证(正常情况下:<mvc:annotation-driven/> 是 enoguht)
    • 检查 JSR 303 验证器实现是否已部署

    【讨论】:

      猜你喜欢
      • 2016-11-29
      • 2016-02-01
      • 2020-09-23
      • 2010-12-05
      • 2011-06-14
      • 2015-01-10
      • 2016-02-24
      • 2011-01-18
      • 2018-06-20
      相关资源
      最近更新 更多