이번 포스팅에서는 resources 폴더와 관련된 static, templates 폴더에 대해 간략히 정리하고자 한다.
/static: 웹 개발 방법(static contents, MVC+template Engine, API) 중 하나인 static contents*가 위치하는 곳으로 html, CSS, javaScript 등을 저장한다. SpringBoot 라이브러리에 포함되어있는 WepProperties.java에서 Resources()는 static file 경로에 대해 다음과 같이 설정되어있다.
/templates: view에 사용할 thymeleaf 파일이 위치하며, SpringBoot에서는 기본적으로 thymeleaf라는 template를 이용해 html을 불러온다.
SpringBoot는 기본적으로 thymeleaf에 대한 auto-configuration을 지원하고 있으며, 자동 인식을 위해서는 src/main/resources/templates에 파일을 저장해야한다고 안내하고 있다(참조).
* static contents: 정적 컨텐츠, html 파일을 그대로 전달하여, 웹페이지에 보여지는 파일로 파일명 그대로 접속이 가능
➕ 만일 static 폴더가 아닌 다른 폴더에서 정적 컨텐츠를 관리하고 싶다면, 다음과 같은 추가 설정이 필요하다.
1. Configuration 파일 생성 후, implement WebMvcConfigurer