JavaScud | Forum | JIRA | Blog |
  Dashboard > WebWork2文档中文化计划 > ... > J2SE 5 Support > StringLengthFieldValidator Annotation
  WebWork2文档中文化计划 Log In View a printable version of the current page.  
  StringLengthFieldValidator Annotation
Added by scud, last edited by scud on May 18, 2006  (view change)
Labels: 
(None)

StringLengthFieldValidator 标注

这个校验器检查一个字符串字段是否在要求的长度内.它假设这个字段是一个字符串.如果minLength和maxLength都没有指定,任何事情都不会发生.

使用

这个标注必须使用在方法级别上.

参数

参数 必填 缺省值 备注
message yes   字段错误信息
key no   语言相关的属性文件里面的i18n key.
fieldName no    
shortCircuit no false 校验器是否短路.
type yes ValidatorType.FIELD 校验器类型(ValidatorType)的枚举值(Enum value). 在这里可以是 FIELD 或者 SIMPLE.
trim no true Boolean 属性. 确定检查长度之前是否要trim字符串.
minLength no   Integer 属性. 字符串最小允许长度.
maxLength no   Integer 属性. 字符串最大允许长度.

如果minLength和maxLength都没有指定,任何事情都不会发生.

例子

@StringLengthFieldValidator(message = "Default message", key = "i18n.key", shortCircuit = true, trim = true, minLength = "5",  maxLength = "12")
Site running on a free Atlassian Confluence Open Source Project License granted to WebWork China. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.3 Build:#808 May 29, 2007) - Bug/feature request - Contact Administrators