Skip to content

Instantly share code, notes, and snippets.

@suhanlee
Created November 22, 2017 08:05
Show Gist options
  • Save suhanlee/dab4c04725279ac2582975d7562baa88 to your computer and use it in GitHub Desktop.
Save suhanlee/dab4c04725279ac2582975d7562baa88 to your computer and use it in GitHub Desktop.
public class AppConfig extends WebMvcConfigurerAdapter{
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource bean = new ReloadableResourceBundleMessageSource();
bean.setBasename("classpath:messages");
bean.setDefaultEncoding("UTF-8");
return bean;
}
@Bean
public LocalValidatorFactoryBean validator() {
LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean();
bean.setValidationMessageSource(messageSource());
return bean;
}
@Override
public Validator getValidator() {
return validator();
}
}
@Size(min = 5, max = 12, message = "{category.name.size}")
private String name;
category.name.size = "The category must be {min} to {max} characters in length.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment