복붙노트

[SPRING] thymeleaf에 message.properties를 포함시키는 방법

SPRING

thymeleaf에 message.properties를 포함시키는 방법

나는 thymeleaf와 함께 봄 부츠를 사용하고 있습니다. 이것은 내 프로젝트 구조입니다.

그리고 이것은 내 앱 시작 클래스입니다.

    @EnableAutoConfiguration
@Configuration
@ComponentScan
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class);
    }
}

내 집에 있습니다 .leaf.html :

하지만이 응용 프로그램을 실행할 때 이것은 내가 얻는 것입니다 : ?? username_en_US ??

이 구성 문제를 해결하는 방법에 대해 여러 가지 시도를했습니다. 제발, 누구든지 도와 줄 수 있니?

해결법

  1. ==============================

    1.스프링 부트에 대한 공식 문서를 참조하십시오.

    스프링 부트에 대한 공식 문서를 참조하십시오.

    http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-convert-an-existing-application-to-spring-boot

    그것은 말한다 :

    그래서 당신은 messages.properties로서 ur 국제화 파일을 만들고 루트 classpath에 놓아야합니다.

    또는 application.properties 파일에이 항목을 추가하여 기본 위치를 더 적절한 위치로 편집 할 수도 있습니다

    #messages
    spring.messages.basename=locale/messages
    

    따라서 messages.properties라는 이름 또는 특정 언어로 자원 폴더 내의 로케일 폴더에 파일을 저장할 수 있습니다.

  2. from https://stackoverflow.com/questions/30106659/how-to-include-message-properties-with-thymeleaf by cc-by-sa and MIT license