Notice
Recent Posts
Recent Comments
05-18 00:26
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Byeol Lo

Spring - static 폴더 본문

BackEnd/Spring

Spring - static 폴더

알 수 없는 사용자 2022. 8. 24. 13:06

Spring은 기본 설정으로 정적컨텐츠를 static폴더에서 찾아서 제공한다. 변하지 않는 html 파일을 넣은 다음 url Path에 Application을 실행시켜주면 된다.

//src/main/resources/static/hello.html

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>hello</title>
</head>
<body>
	<p>hihi</p>
</body>
</html>

해당 파일을 넣고 실행시킨 후에 localhost:8080/hello.html로 들어가면 해당 파일을 그대로 제공해준다.

웹 클라이언트 > 내장 톰캣 서버 > 스프링 컨테이너(hello 관련 컨트롤러를 찾음) > 없으면 resources의 static/hello.html을 찾음 그런 후에 반환을 함.

'BackEnd > Spring' 카테고리의 다른 글

Spring IOC(Inversion of Control), DI(Dependency Injection)  (0) 2022.08.30
Spring - MVC와 템플릿 엔진  (0) 2022.08.28
build.gradlew  (0) 2022.08.24
Spring 시작하기  (0) 2022.08.21
Comments