본문 바로가기
프로젝트/Recipository

[Dev] 22.09.14. static과 templates directory

by 규글 2022. 9. 14.

static과 templates directory

 만든 project의 형태를 보면 src > main > resources 하위에 static과 templates가 존재한다. 각각의 folder에는 어떤 친구들이 들어가게 되는지 궁금해져서 검색을 해봤다.

 

 위 글을 발견한 곳이다.[각주:1] 글을 정리하면 다음과 같다.

 

static directory

static directory는 js, css, 사진 등의 static(정적) file을 저장할 때 사용하는 directory이다. Server로부터의 data binding이 필요하지 않은 페이지도 이곳에 포함될 수 있다.

 

templates directory

Freemarker, jsp, thymeleaf, 서버로부터의 dynamic(동적) rendering이 필요한 dynamic template file을 저장할 때 사용하는 directory이다. Page rendering에 server의 data를 필요로하기 때문에 파일은 Model data에 대해 controller를 통해 bound 되어야 하며, direct access가 무의미하고 접근 불가능하다. 주소창을 통한 접근을 할 수 없고, controller를 통해 접근해야 한다.

 

 즉, 글자 그대로 정적인 것은 static에, 동적인 것은 templates에 위치하면 되는 것 같다. 그리고 thymeleaf를 사용할 것이라고 언급했었는데, 이 역시 특정 elements들의 구조를 가져다가 쓸 수 있는 구조이기도 하고 server의 data를 binding 시킬 수 있기때문에 동적이라고 표현하는 것 같다. 관련 내용은 검색을 통한 여러 블로그에서도 발견할 수 있다.

 

Reference

댓글