Spring 입문

<Spring 입문> 3.1 스프링 웹 개발 기초_정적 콘텐츠

Isaac01 2025. 4. 16. 14:51
반응형

정적 콘텐츠 (Static Content)

  • src/main/resources/static/ 폴더 안에 있는 파일들
  • 예: hello.html, style.css, logo.png 등
  • 브라우저가 /hello.html 요청 → 가공하지 않은 파일 그대로 응답

 

정적 콘텐츠  확인해 보기

src > main > resources > static > hello.html 파일을 만들고 다음 코드를 입력했다.

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

 

 

URL에 localhost:8080/hello.html 를 입력하고 페이스 소스보기를 클릭해 보면  hello.html 파일 그대로가 View에 전달되었음을 확인 할 수 있다.

 

정적 콘텐츠랑 Welcome Page는 같은 것일까?

결론 부터 말하면 아니다.

Welcome Page는 정적 콘텐츠 wnddptj  요청을 처리하는 특별한 파일(index.html)을 말한다.

항목                                   정적 콘텐츠                                                                   Welcome Page
위치 static, public 등 static 등
파일 이름 제한 없음 (hello.html, about.css 등) index.html
동작 요청한 경로 그대로 응답 루트 경로 / 요청 시 자동 응답
뷰 처리 방식 그대로 응답 그대로 응답
템플릿 엔진 사용 ❌ (Thymeleaf 등 사용 안 함) ❌ (단순 HTML)