반응형
클래스 경로에서 HTML 파일을 로드하는 스프링 부트 타임리프
저는 다음과 같은 다중 모듈 프로젝트 구조를 가지고 있습니다.
- application (parent module)
--- boot (web-app)
----- src/main/resources/templates/layout.html
---- todo (jar file)
----- src/main/resources/templates/home.html
그리고 내 컨트롤러에서:
@RequestMapping(value = "/home")
public String home() {
return "todo/home";
}
다음과 같은 오류 메시지가 표시됩니다.
Error resolving template "todo/home", template might not exist or
might not be accessible by any of the configured Template
Resolvers]
클래스 경로에서 템플릿을 검색하기 위해 봄용으로 특별히 구성해야 하는 구성이 있습니까?
다음 속성을 추가하면 문제가 해결됩니다.
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
언급URL : https://stackoverflow.com/questions/29479403/spring-boot-thymeleaf-load-html-file-from-classpath
반응형
'programing' 카테고리의 다른 글
기존 시트에 새 열을 추가하고 이름을 지정하는 방법은 무엇입니까? (0) | 2023.07.11 |
---|---|
argparse로 구문 분석된 값을 어떻게 제한할 수 있습니까(예: 정수를 양의 값으로 제한)? (0) | 2023.07.11 |
재사용 가능하고 동적인 탭 메뉴를 생성하는 데 사용하는 v-for 내부 구성 요소 사용 (0) | 2023.07.11 |
jQuery 클래스 이름 변경 (0) | 2023.07.11 |
ON 키워드 없이 INNER JOIN이 가능한가요? (0) | 2023.07.11 |