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" 라는 절대경로를 리턴하니 경로 오류가 발생하는거였습니다.
경로를 지정할 때 주의해야 할 점입니다.
'프로그래밍' 카테고리의 다른 글
[AI] OpenAI o3-mini 출시 (0) | 2025.02.01 |
---|---|
네이버클라우드 - SourcePipeline 사용하기 (0) | 2023.06.14 |
thymeleaf 의 layout:decorate 가 동작하지 않을 때 (0) | 2023.06.05 |
Springboot 와 Elasticsearch 연동하기 (0) | 2023.06.02 |
Gitbook Init 오류 - cb.apply is not a function (0) | 2023.04.13 |