프로그래밍
Springboot - TemplateInputException (Error resolving templete 오류)
tedhong
2023. 6. 7. 17:09
local 에서 이상없이 동작하던 웹 페이지를
서버에서 구동시키니 에러코드 500 과 함께 이런 메세지가 출력되었습니다.
org.thymeleaf.exceptions.TemplateInputException:
Error resolving template [/test/index],
template might not exist or might not be accessible
by any of the configured Template Resolvers
대충 경로'/test/index '에 지정된 templete 파일을 못찾는다는 얘기인데
오류 메세지가 이게 전부라 디버깅이 어려웠습니다..
결국 구글링으로 해결했는데요,
원인은 Requestmapping 어노테이션이 붙어있는 Controller 함수가 return 하는
templete URL 이 '/' 로 시작해서였습니다.
그래서 '/test/index' 이걸 'test/index' 이렇게 바꾸니 해결되었어요.
@RequestMapping("/getTest")
public String index() {
return "test/index"; // <-- 이 부분
}
이유는 application.properties 에
spring.thymeleaf.prefix=classpath:/templates/
이렇게 설정되어 있는데 또 이렇게 "/test/index" 라는 절대경로를 리턴하니 경로 오류가 발생하는거였습니다.
경로를 지정할 때 주의해야 할 점입니다.