How can we resolve a message from properties file? Just like when we use
errors.reject ( "xyz.abc" );
in this case "xyz.abc" is resolved from the property file specified in messageResource ( servlet.xml )
How can we resolve a message from properties file? Just like when we use
errors.reject ( "xyz.abc" );
in this case "xyz.abc" is resolved from the property file specified in messageResource ( servlet.xml )
Implement the MessageSourceAware
interface in your class. Something like this should do the trick.
public class Foo implements MessageSourceAware {
protected MessageSource messageSource;
...
public void setMessageSource(MessageSource messageSource) {
this.messageSource = messageSource;
}
...
public String bar(HttpServletRequest request, ...) {
return messageSource.getMessage("xyz.abc",
new Object[] { "arg1", "arg2" },
RequestContextUtils.getLocale(request));
}
}