msg是用来指定当校验不通过时,Validator框架所给出的提示信息。它的值是应用所配置的资源文件中的一个关键字,当校验失败时,Validator框架利用msg所指定的值到应用配置的资源文件中去查找匹配记录。Validator框架默认使用以下提示信息:
errors.required={0} is required.
errors.minlength={0} cannot be less than {1} characters.
errors.maxlength={0} cannot be greater than {1} characters.
errors.invalid={0} is invalid.
errors.byte={0} must be a byte.
errors.short={0} must be a short.
errors.integer={0} must be an integer.
errors.long={0} must be a long.
errors.float={0} must be a float.
errors.double={0} must be a double.
errors.date={0} is not a date.
errors.range={0} is not in the range {1} through {2}.
errors.creditcard={0} is not a valid credit card number.
errors.email={0} is an invalid email address
可以将上面的这些信息添加到你的Struts应用所配置的资源文件(例如:ApplicationResources.properties)中,也可以修改这些值之后,将其添加到配置文件中,示例如下:
errors.required={0} 是必填项。 |