Springboot

[Spring Boot] 스프링 부트 프로젝트 Welcome Page 만들기

Jenny376 2022. 11. 29. 20:14
안녕하세요. hia의 개발 story입니다.

 

프로젝트의 가장 기본으로 Hello World 페이지를 만들어서 index 파일이 잘 읽히는지 확인하려고 합니다.

스프링 부트에서는 기본적으로 welcome page를 지원해줍니다. 

공식 문서에서 보이듯이 파일명을 index로 설정하면 자동으로 welcome page로 인식을 합니다.

정확히는 프로젝트 실행 시에 스프링 부트에서 가장 먼저 index를 찾아서 가죠. 

 

 

Spring Boot Features

Graceful shutdown is supported with all four embedded web servers (Jetty, Reactor Netty, Tomcat, and Undertow) and with both reactive and Servlet-based web applications. It occurs as part of closing the application context and is performed in the earliest

docs.spring.io

그러면 이제 intellij에서 처음으로 html 파일을 만들어 보겠습니다. 

index 파일 위치는 static 으로 위치해주면 됩니다. 

Command + N 을 누르고 html 파일을 찾아서 index로 만들어줍니다. 

 

만들어진 index 파일이 잘 실행되는지 확인하기 위해서 간단하게 Hello World!! 를 띄워보도록 하겠습니다.

<h1>hello world!!</h1>을 body 안에 적어줍니다. 

저장을 하고 재실행을 하고 localhost에 접속하면 아래 화면처럼 hello world가 잘 보이게 됩니다.