고래씌
[Spring] 1. header, footer만들기 본문
1. header, footer 만들기
=> WEB-INF폴더 아래에 views 폴더 생성하고 그 안에 board, chat, common, member, main.jsp 생성
▶ HomeController.java
package com.kh.spring;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class HomeController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home() {
return "main";
}
}
=> index.jsp가 아닌, main.jsp가 나올 것임
▶ common > header.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- 공통적으로사용할 라이브러리 추가 -->
<!-- Jquey 라이브러리 -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- 부트스트랩에서 제공하있는 스타일 -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- 부투스트랩에서 제공하고있는 스크립트 -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<!-- alertify -->
<script src="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/alertify.min.js"></script>
<!-- alertify css -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css"/>
<!-- Default theme -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/default.min.css"/>
<!-- Semantic UI theme -->
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/semantic.min.css"/>
<style>
div {box-sizing:border-box;}
#header {
width: 80%;
height: 130px;
padding-top:20px;
margin :auto;
/* 추가 */
position: sticky;
top: 0; /* 최상단에 붙임*/
background-color: white;
border-bottom : 2px solid black;
z-index: 10;
}
#header>div{width:100%; margin-bottom: 10px;}
#header_1 {height : 40%;}
#header_2 {height : 60%;}
#header_1>div{
height:100%;
float:left;
}
#header_1_left {width :30%; position : relative;}
#header_1_center{width: 40%;}
#header_1_right{width : 30%;}
#header_1_left>img{
height:80%; position:absolute; margin:auto; top:0px; bottom:0px; right:0px; left :0px;
}
#header_1_right {text-align:center; line-height: 35px; font-size: 12px; text-indent:35px;}
#header_1_right>a{margin:5px;}
#header_1_right>a:hover{cursor:pointer}
#header_2>ul{width:100%; height:100%; list-style-type : none; margin:auto; padding: 0;
display: flex; /* 추가 */
}
#header_2>ul>li {float:left; width: 25%; height:100%; line-height: 55px; text-align:center;}
#header_2>ul>li a {font-size: 18px; font-weight:900}
#header_2 {border-top : 1px solid lightgray;}
#header a {text-decoration:none; color:black;}
/* 세부페이지에 들어갈 공통 css 부여*/
.content{
background-color: pink;
width:80%;
margin:auto;
}
.innerOuter{
border:1px solid lightgray;
width: 80%;
margin:auto;
padding: 5% 10%;
background-color : white;
}
</style>
</head>
<body>
<div id="header">
<div id="header_1">
<div id="header_1_left">
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxAQEBUQEBAWFhUVFhUXFxUVFRcVFRcXFhUXFxUVFRcYHSggGBolHhUVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGhAQGy0lICUtLS0vLS0tLS01LS8tLS0tLS0tLS0tLS01LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAMwA9wMBIgACEQEDEQH/xAAbAAEAAgMBAQAAAAAAAAAAAAAAAQQCAwUGB//EADsQAAIBAgMFBQcCBgAHAAAAAAABAgMRBBIhBTFBUWFxgZGx8AYTIjKh0eEUwQcjQlJi8TNDgpKistL/xAAZAQEAAwEBAAAAAAAAAAAAAAAAAQIDBAX/xAAkEQACAgICAgIDAQEAAAAAAAAAAQIRAyESMUFRBCITYZEyQv/aAAwDAQACEQMRAD8A+0kgAkAAAEg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" value="<%= request.getContextPath() %>" />
<c:choose>
<c:when test="${empty loginUser}">
<!-- 로그인이전이라면 -->
<a href="${contextPath}/insert.me">회원가입</a>
<!-- 모달창 설정: data-target에 정의해놓은 아이디의 dom요소를 띄워줌 -->
<a data-toggle="modal" data-target="#loginModal">로그인</a>
</c:when>
<c:otherwise>
<!-- 로그인이후라면 -->
<label>${loginUser.userName}님 환영합니다.</label>
<a href="${contextPath}/myPage.me">마이페이지</a>
<a href="${contextPath}/logout.me">로그아웃</a>
</c:otherwise>
</c:choose>
</div>
</div>
<div id="header_2">
<ul>
<li><a href="${contextPath}">HOME</a></li>
<li><a href="${contextPath}/chat/chatRoomList">채팅</a></li> <!-- 채팅방목록 -->
<li><a href="${contextPath}/board/list/C">일반게시판</a></li>
<li><a href="${contextPath}/board/list/T">사진게시판</a></li>
</ul>
</div>
</div>
<!-- 로그인 클릭시 뜨는 모달창 -->
<div class="modal fade" id="loginModal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- 모달 해더 -->
<div class="modal-header">
<h4 class="modal-title">Login</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form action="${contextPath }/login.me" method="post">
<!-- 모달 바디 -->
<div class="modal-body">
<label for="userId" class="mr-sm-2">ID : </label>
<input type="text" class="form-controll mb-2 mr-sm-2" placeholder="Enter ID" id="userId" name="userId"> <br>
<label for="userPwd" class="mr-sm-2">PWD : </label>
<input type="password" class="form-controll mb-2 mr-sm-2" placeholder="Enter Password" id="userPwd" name="userPwd">
</div>
<!-- 모달 푸터 -->
<div class="modal-footer">
<button type="submit" class="btn btn-primary">로그인</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">취소</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
▶ footer.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
/* div{border:1px solid red;} */
#footer {
width:80%;
height:200px;
margin:auto;
margin-top:50px;
}
#footer-1 {
width:100%;
height:20%;
border-top:1px solid lightgray;
border-bottom:1px solid lightgray;
}
#footer-2 {width:100%; height:80%;}
#footer-1, #footer-2 {padding-left:50px;}
#footer-1>a {
text-decoration:none;
font-weight:600;
margin:10px;
line-height:40px;
color:black;
}
#footer-2>p {
margin:0;
padding:10px;
font-size:13px;
}
#p2 {text-align:center;}
</style>
</head>
<body>
<div id="footer">
<div id="footer-1">
<a href="#">이용약관</a> |
<a href="#">개인정보취급방침</a> |
<a href="#">인재채용</a> |
<a href="#">고객센터</a>
</div>
<div id="footer-2">
<p id="p1">
강남지원 1관 : 서울특별시 강남구 테헤란로14길 6 남도빌딩 2F, 3F, 4F, 5F, 6F <br>
강남지원 2관 : 서울특별시 강남구 테헤란로10길 9 그랑프리 빌딩 4F, 5F, 7F <br>
강남지원 3관 : 서울특별시 강남구 테헤란로 130 호산빌딩 5F, 6F <br>
종로지원 : 서울특별시 중구 남대문로 120 대일빌딩 2F, 3F <br>
당산지원 : 서울특별시 영등포구 선유동2로 57 이레빌딩 (구관) 19F, 20F
</p>
<p id="p2">Copyright © 1998-2022 KH Information Educational Institute All Right Reserved</p>
</div>
</div>
</body>
</html>
▶ main.jsp
=> inculde 지시어를 통해 header와 footer 추가
'Server > Spring' 카테고리의 다른 글
[Spring] 4. 예외처리 (0) | 2024.01.23 |
---|---|
[Spring] 3. 마이페이지 수정하기, alertMsg 띄우기 (0) | 2024.01.23 |
[Spring] 2-2. 회원가입 페이지, 비밀번호 암호화 저장 (0) | 2024.01.22 |
[Spring] 2-1. 로그인, 로그아웃 페이지 (0) | 2024.01.22 |
[Spring] 0. Spring 환경설정 (2) | 2024.01.19 |