스프링 부트, 입문!

스프링 부트, 입문!

쉽고 빠르게 배우는, 스프링 부트 첫걸음!

06 뷰 템플릿과 레이아웃

# 뷰 템플릿과 레이아웃 ## 미션 뷰 템플릿 페이지에 헤더-푸터 레이아웃을 적용하시오. ![홍팍-스프링-부트-입문-뷰-템플릿-레이아웃-미션](http://drive.google.com/thumbnail?export=view&sz=w960&id=1doaSUFBm0xVO9CIMjnJ_HoTL1om0x4Ws) ## 02:43 부트스트랩 적용하기 #### ../resources/templates/greetings.mustache ``` <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <title>Hello, world!</title> </head> <body> <!-- navigation --> <!-- content --> <h1>{{username}}님, 반갑습니다.</h1> <!-- site info --> <!-- Optional JavaScript; choose one of the two! --> <Script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> </body> </html> ``` ## 05:19 네브바 추가 #### navbar 코드 블럭 ``` <!-- navigation --> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <div class="container-fluid"> <a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li><hr class="dropdown-divider"></li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> <form class="d-flex"> <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success" type="submit">Search</button> </form> </div> </div> </nav> ``` ## 06:27 하단 정보 넣기 #### 사이트 하단 코드 블럭 ``` <!-- site info --> <div class="mb-5 container-fluid"> <hr> <p>ⓒ CloudStudying | <a href="#">Privacy</a> | <a href="#">Terms</a></p> </div> ``` #### 사이트 중단 코드 블럭 ``` <!-- content --> <div class="bg-dark text-white p-5"> <h1>{{username}}님, 반갑습니다.</h1> </div> ``` ## 08:36 레이아웃 템플릿 생성 및 활용 #### ../templates/goodbye.mustache ``` {{>layouts/header}} <div class="bg-dark text-white p-5"> <h1>{{nickname}}님, 다음에 또 만나요!</h1> </div> {{>layouts/footer}} ``` #### ../templates/greetings.mustache ``` {{>layouts/header}} <!-- content --> <div class="bg-dark text-white p-5"> <h1>{{username}}님, 반갑습니다.</h1> </div> {{>layouts/footer}} ``` #### ../templates/layouts/header.mustache ``` <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"> <title>Hello, world!</title> </head> <body> <!-- navigation --> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <div class="container-fluid"> <a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li><hr class="dropdown-divider"></li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> <li class="nav-item"> <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a> </li> </ul> <form class="d-flex"> <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success" type="submit">Search</button> </form> </div> </div> </nav> ``` #### ../templates/layouts/footer.mustache ``` <!-- site info --> <div class="mb-5 container-fluid"> <hr> <p>ⓒ CloudStudying | <a href="#">Privacy</a> | <a href="#">Terms</a></p> </div> <!-- Optional JavaScript; choose one of the two! --> <Script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> </body> </html> ``` ## 🔥 구글링 훈련하기 - 부트스트랩이란 - 머스테치 partial view