본문 바로가기
Framekwork/SPRING

[자바/스프링] 정적 컨텐츠 (static)

by 아이엠제니 2023. 2. 12.

 

 

스프링 웹 개발 기초

  1. 정적 컨텐츠
    • 파일을 웹 브라우저에 그대로 내려주는 거
  2. MVC와 템플릿 엔진
    • JSP나 PHP가 템플릿 엔진임. html을 그냥 주는 게 아니라 서버에서 프로그래밍을 해서 html을 동적으로 바꿔서 내리는 거
    • model-view-controller 패턴으로 개발을 함
  3. API
    • JSON 포맷으로 클라이언트에게 데이터를 전달
    • 서버끼리 통신할 때 활용

 

✔️ 정적 컨텐츠와 MVC/템플릿 엔진의 차이는!

  • 정적 컨텐츠는 웹 페이지에 파일을 그대로 내려주는 거
  • MVC/템플릿 엔진은 서버에서 변형을 해서 내려주는 거

정적 컨텐츠

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.static-content

 

💾resources > static > hello-static.html

<!doctype html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>static content</title>
</head>
<body>
정적 컨텐츠입니다.
</body>
</html>

  • `hello-static.html`로 들어가면 텍스트가 나오는 걸 확인할 수 있다.

 

✔️ 정적 컨텐츠 이미지

  • Controller가 우선순위를 가짐. 그래서 Controller에서 `hello-static.html`이 있는지 찾아봄
  • 그 다음에 resources/static에서 `hello-static.html`이 있는지 찾음

 

 

 

[스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술] 강의 기록
300x250