스프링 웹 개발 기초(1) : 정적컨텐츠

sylvie·2021년 10월 30일
0

스프링부트

목록 보기
5/11

정적 컨텐츠

정적 컨텐츠란?

서버에서 별다른 작업이 이루어지지않고 html 파일을 그대로 넘겨줘서 보여주는 것.

스프링 부트 정적 컨텐츠 기능

Spring boot는 static resources에 대한 기본 매핑 설정과 커스텀을 지원한다.
7.1.5. Static Content

resources/static/hello-static.html
<!DOCTYPE HTML>
  <html>
  <head>
      <title>static content</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  </head>
<body>
정적 컨텐츠 입니다.
  </body>
  </html>

실행

http://localhost:8080/hello-static.html

동작 환경 그림


'웹 브라우저'에서 url을 요청을 하면 '내장 톰캣 서버'가 요청을 받은 뒤 spring에게 넘긴다.
spring은 먼저, controller에서 'hello-static' 관련 매핑된 controller를 찾은다. (controller가 우선순위를 먼저 가진다는 의미.) 이때 찾지 못하면, 'resources/static/hello-static.html'을 찾는다.
이와 같은 경우를 정적 컨텐츠라 한다.

0개의 댓글