반응형
정적 페이지 생성 예제
- Spring Boot 프로젝트의 src\main\resources\static 폴더 안에 index.html, staticpage.html 파일 생성
- index.html 파일에 아래의 코드 입력
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Index Page</title>
</head>
<body>
인덱스 페이지
</body>
</html>
- staticpage.html 파일에 아래의 코드 입력
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Static Page</title>
</head>
<body>
정적 페이지
</body>
</html>
결과
- 주소창에 http://localhost:8080 을 입력하면 index.html이 출력되는 것을 확인할 수 있음
- Spring boot에서 index.html은 따로 설정을 안해줘도 기본 url로 배정됨
- 주소창에 http://localhost:8080/staticpage.html 입력하면 staticpage.html을 확인할 수 있음
반응형
'Spring Boot > 문법 정리' 카테고리의 다른 글
[Spring Boot] DI, @Autowired, @RequiredArgsConstructor (0) | 2022.05.17 |
---|---|
[Spring Boot] 테스트 코드 작성 예제 (0) | 2022.05.12 |
[Spring Boot] @RestController, lombok (0) | 2022.04.29 |
[Spring Boot] MVC 정의 및 예제 (0) | 2022.04.26 |
[Spring Boot] 프로젝트 생성 및 실행, Java 버전 에러 해결 방법 (0) | 2022.04.26 |