org.thymeleaf.exceptions.TemplateInputException 에러해결

최대 1 분 소요

에러발생

spring 공부 중 웹 MVC 확인을 하기위해서

home.html 파일을 만들고

controller 부분에서 return "home"을 했으나

Cannot resolve MVC view ‘home’ 오류가 발생했고

역시나 실행시켰을 때 아래와 같은 에러가 발생했다.

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [home], template might not exist or might not be accessible by any of the configured Template Resolvers

image

image

원인

  • home.html을 templates 폴더에 만들지 않고, static 폴더에 만들어서…

  • 스프링이 계속 버전이 올라가면서 view 엔진이 thymeleaf로 바뀌었는데

    templates 폴더가 thymeleaf 파일을 두는 곳이라고 한다.

  • static 폴더에는 해당 파일을 view를 통해서 확인하는게 아닌 그 자체로 반환하는 html 파일을 올려야 한다.

    static 폴더는 css나 js을 파일을 두는 곳

Reference


https://stackoverflow.com/questions/5905896/intellij-inspection-gives-cannot-resolve-symbol-but-still-compiles-code

https://donghyeon.dev/spring/2019/07/02/%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A%B8-static%EA%B3%BC-template-%EC%B0%A8%EC%9D%B4/

카테고리:

업데이트:

댓글남기기