Spring, Thymeleaf and localized strings

Viewed 8061

I am new to using Spring and Thymeleaf and I can't figure out where to put my localization .properties files. I have this Bean:

@Bean
public MessageSource messageSource() {

    ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
    messageSource.setBasenames("classpath:messages/messages", "classpath:messages/validation");
    // if true, the key of the message will be displayed if the key is not
    // found, instead of throwing a NoSuchMessageException
    messageSource.setUseCodeAsDefaultMessage(false);
    messageSource.setDefaultEncoding("UTF-8");
    // # -1 : never reload, 0 always reload
    messageSource.setCacheSeconds(0);

    return messageSource;
}

Inside login.html:

    <p th:text="#{messages.hello}">Welcome to our site!</p>

Inside messages_en.properties :

    messages.hello=Apparently messages work

My project structure:

structure

I have tried creating a folder inside WEB-INF called messages but apparently I am not getting something right. Any ideas?

Edit: Updated question with code relevant to mesages.

3 Answers
Related