validation - Struts 2 @RequiredStringValidator messageParams -


in message resources file have following lines:

error.required={0} required labels.email=e-mail 

to validate e-mail field using annotation validators, this:

@requiredstringvalidator(key="error.required") public string getemail() {     return email; } 

my question is: how can pass labels.email resource value {0} param message using requiredstringvalidator annotation? trying messageparam property without success.

try this

@requiredstringvalidator(message = "${gettext('error.required', new java.lang.string[] {gettext('labels.email')})}") 

the gettext() used if action extends actionsupport resource messages key specified parameter. applied 2 times in same expression build message. first time without parameter, second parameter , used overloaded gettext() implementation.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -