๊ตฌํ ์์ ( ๋ฐ์ดํฐ๋ฒ ์ด์ค ๐๐ป ์๋ฒ ๐๐ป ํ๋ก ํธ ๐๐ป ๋ฐฑ์๋ )
1) [์ ๋ณด์ฒ๋ฆฌ์ฐ์ ๊ธฐ์ฌ ๊ณผ์ ํ๊ฐํ] ์ค๊ธฐ์ํ ๋ฌธ์ - ์ง์ญ๊ตฌ์์ํฌํ
2) [์ ๋ณด์ฒ๋ฆฌ์ฐ์ ๊ธฐ์ฌ ๊ณผ์ ํ๊ฐํ] ์ค๊ธฐ MVC ํจํด ๊ตฌ์กฐ / ํ๋ฆ
3) [์ ๋ณด์ฒ๋ฆฌ์ฐ์
๊ธฐ์ฌ ๊ณผ์ ํ๊ฐํ] ์ง์ญ๊ตฌ์์ํฌํ - DB ์์ฑํ๊ธฐ
4) [์ ๋ณด์ฒ๋ฆฌ์ฐ์
๊ธฐ์ฌ ๊ณผ์ ํ๊ฐํ] ์ง์ญ๊ตฌ์์ํฌํ - Java / Servlet ์์ฑ
5) [์ ๋ณด์ฒ๋ฆฌ์ฐ์
๊ธฐ์ฌ ๊ณผ์ ํ๊ฐํ] ์ง์ญ๊ตฌ์์ํฌํ - View ํ๋ฉด ๋ง๋ค๊ธฐ
6) [์ ๋ณด์ฒ๋ฆฌ์ฐ์
๊ธฐ์ฌ ๊ณผ์ ํ๊ฐํ] ์ง์ญ๊ตฌ์์ํฌํ - ๋ฐ์ดํฐ ์
/์ถ๋ ฅ
โจ Step3. View ํ๋ฉด ๋ง๋ค๊ธฐ ( JSP ํ์ผ ์์ฑ)
- topmenu.jsp (<header>, <nav>)
- footer.jsp (<footer>)
- index.jsp (ํ์ผ๋ก)
- memberList.jsp (ํ๋ณด์กฐํ)
- voteMember.jsp (ํฌํํ๊ธฐ)
- voteList.jsp (ํฌํ๊ฒ์์กฐํ)
- voteResult.jsp (ํ๋ณด์ ๋ฑ์)
- style.css
- script.js
ํ๋ฉด์ ๋ณด์๋ฉด <header>, <nav>, <section>, <footer> ๋ก ๋๋์ด์ ธ์์ต๋๋ค.
JSP ์ include๋ฅผ ํ์ฉํ๊ธฐ ์ํด topmenu.jsp, footer.jsp, style.css, script.js(์ ํจ์ฑ์ฒดํฌ) ๋ฅผ ์์ฑํ๊ฒ ์ต๋๋ค.
(์ ์ฒด ์์คํ์ผ์ ๋ง์ง๋ง ํฌ์คํ ์ ์ ๋ก๋ ํ๊ฒ ์ต๋๋ค.)
โtopmenu.jsp ( css ํ์ผ์ ์ฐ๊ฒฐ (link) ํด์ค์ผ๋ก์จ topmenu๋ฅผ includeํ๋ ๋ชจ๋ ํ์ผ์ ์ ์ฉ๋๊ฒ ํฉ๋๋ค.)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ง์ญ๊ตฌ์์ํฌํ</title>
<link rel="stylesheet" href="style.css?ver=1">
</head>
<body>
<header>
<h1>(๊ณผ์ ํ๊ฐํ ์ ๋ณด์ฒ๋ฆฌ์ฐ์
๊ธฐ์ฌ)์ง์ญ๊ตฌ์์ํฌํ ํ๋ก๊ทธ๋จ ver 2020-05</h1>
</header>
<nav>
<ul>
<li><a href="memberList.do">โํ๋ณด์กฐํ</a></li>
<li><a href="voteMember.do">โํฌํํ๊ธฐ</a></li>
<li><a href="voteList.do">โํฌํ๊ฒ์์กฐํ</a></li>
<li><a href="voteResult.do">โํ๋ณด์๋ฑ์</a></li>
<li><a href="main.do">โํ์ผ๋ก</a></li>
</ul>
</nav>
</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>
<body>
<footer>
HRDKOREA Copyright@2015 All rights reserved. Human Resources Development Service of Korea
</footer>
</body>
</html>
โstyle.css
@charset "UTF-8";
*{
margin:0;
padding:0;
}
body{
font-family:gulim;
font-size:1.2em;
color:#454545;
text-align:center;
}
header{
width:100%;
height:160px;
line-height:160px;
background-color:#7d9caf;
color:#f1f1f1;
}
nav ul{
width:100%;
height:60px;
line-height:60px;
background-color:#555f6d;
color:#f1f1f1;
}
nav ul li{
font-size:1em;
list-style:none; /* li ์์ ํ์๋ฅผ ์ ๊ฑฐํ๋ค. */
float:left;
padding:0 10px;
}
a{
text-decoration:none;
color:#f1f1f1;
}
a:hover{
background-color:#f1f1f1;
color:#555f6d;
border-radius:2em;
}
section{
position:absolute;
overflow:auto;
width:100%;
height:100%;
background-color:#e1effa;
}
h2{
padding:1.6rem;
}
.table{
display:flex;
justify-content:center;
align-items:center;
}
.table table,th,td{
border:1px solid #454545;
border-collapse:collapse;
padding:5px;
}
table{
width: 500px;
}
td input, select{
float: left;
padding: 0.3rem;
}
.btn{
padding: 0.3rem;
}
.btn:hover{
cursor: pointer;
}
ul li{
list-style:none;
text-align:left;
padding:0 10px 20px;
}
footer{
position:fixed;
bottom:0px;
width:100%;
height:30px;
line-height:30px;
background-color:#7d9caf;
color:#f1f1f1;
}
โscript.js (์ ํจ์ฑ ์ฒดํฌ)
function fn_submit(){
var f = document.frm;
var v_jumin = f.v_jumin.value;
if(v_jumin == ""){
alert("์ฃผ๋ฏผ๋ฒํธ๊ฐ ์
๋ ฅ๋์ง ์์์ต๋๋ค!");
f.v_jumin.focus(); return false;
}
var jumin = /([0-9]{2}(0[1-9]|1[0-2])(0[1-9]|[1,2][0-9]|3[0,1]))/;
//์ฃผ๋ฏผ๋ฒํธ ์ ํจ์ฑ ๊ฒ์ฌ
if(!jumin.test(v_jumin) || v_jumin.length <13 || v_jumin.length >13){
alert("์ ํจํ์ง์์ ์ฃผ๋ฏผ๋ฒํธ ์
๋๋ค.\n ์ซ์ 13์๋ฆฌ๋ก ์
๋ ฅํด์ฃผ์ธ์.");
f.v_jumin.focus(); return false;
}
var v_name = f.v_name.value;
if(v_name == ""){
alert("์ฑ๋ช
์ด ์
๋ ฅ๋์ง ์์์ต๋๋ค!");
f.v_name.focus(); return false;
}
var name = /^[๊ฐ-ํฃ]+$/; //ํ๊ธ์ด๋ฆ ์ ํจ์ฑ ๊ฒ์ฌ
if(!name.test(v_name)){
alert("ํ๊ธ์ด๋ฆ์ผ๋ก ์
๋ ฅํด์ฃผ์ธ์.");
f.v_name.focus(); return false;
}
if(f.m_no.value == ""){
alert("ํ๋ณด๋ฒํธ๊ฐ ์ ํ๋์ง ์์์ต๋๋ค!");
f.m_no.focus(); return false;
}
if(f.v_time.value == ""){
alert("ํฌํ์๊ฐ์ด ์
๋ ฅ๋์ง ์์์ต๋๋ค!");
f.v_time.focus(); return false;
}
if(f.v_time.value.length < 4 || f.v_time.value.length > 4){
alert("ํฌํ์๊ฐ์ ์ซ์4์ ๋ก ์
๋ ฅํด์ฃผ์ธ์! ์)0930");
f.v_time.focus(); return false;
}
if(f.v_area.value == ""){
alert("ํฌํ์ฅ์๊ฐ ์
๋ ฅ๋์ง ์์์ต๋๋ค!");
f.v_area.focus(); return false;
}
if(f.v_area.value != "์ 1ํฌํ์ฅ" && f.v_area.value != "์ 2ํฌํ์ฅ"){
alert("ํฌํ์ฅ์๋ฅผ ์ 1ํฌํ์ฅ or ์ 2ํฌํ์ฅ ์ผ๋ก ์
๋ ฅํด์ฃผ์ธ์ :D");
f.v_area.focus(); return false;
}
if(f.v_confirm.value == ""){
alert("์ ๊ถ์ํ์ธ์ด ์ ํ๋์ง ์์์ต๋๋ค!");
return false;
}
f.submit();
}
function fn_reset(){
alert("์ ๋ณด๋ฅผ ์ง์ฐ๊ณ ์ฒ์๋ถํฐ ๋ค์ ์
๋ ฅํฉ๋๋ค!");
location="voteMember.jsp";
}
function fn_onload(){
document.frm.v_jumin.focus();
document.frm.onload();
}
โindex.jsp (๋ฉ์ธ)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>main</title>
</head>
<body>
<%@ include file="topmenu.jsp" %>
<section>
<h2>๊ณผ์ ํ๊ฐํ ์๊ฒฉ CBQ</h2>
</section>
<%@ include file="footer.jsp" %>
</body>
</html>
โvoteMember.jsp (ํฌํํ๊ธฐ ํ๋ฉด)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>voteMember</title>
</head>
<body>
<%@ include file="topmenu.jsp" %>
<section>
<h2>โ ํฌํํ๊ธฐ โ</h2>
<form name="frm" method="post" action="vote.do">
<div class="table">
<table>
<tr>
<th>์ฃผ๋ฏผ๋ฒํธ</th>
<td>
<input type="text" name="v_jumin"> ์ : 8906153154726
</td>
</tr>
<tr>
<th>์ฑ๋ช
</th>
<td>
<input type="text" name="v_name">
</td>
</tr>
<tr>
<th>ํฌํ๋ฒํธ</th>
<td>
<select name="m_no">
<option></option>
<option value="1">[1]๊นํ๋ณด</option>
<option value="2">[2]์ดํ๋ณด</option>
<option value="3">[3]๋ฐํ๋ณด</option>
<option value="4">[4]์กฐํ๋ณด</option>
<option value="5">[5]์ตํ๋ณด</option>
</select>
</td>
</tr>
<tr>
<th>ํฌํ์๊ฐ</th>
<td>
<input type="text" name="v_time" placeholder="์)0930">
</td>
</tr>
<tr>
<th>ํฌํ์ฅ์</th>
<td>
<input type="text" name="v_area" placeholder="์)์ 1ํฌํ์ฅ">
</td>
</tr>
<tr>
<th>์ ๊ถ์ํ์ธ</th>
<td>
<input style="float:none;" type="radio" name="v_confirm" value="Y">ํ์ธ
<input style="float:none;" type="radio" name="v_confirm" value="N">๋ฏธํ์ธ
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<button class="btn" type="submit" onclick="fn_submit();return false;">ํฌํํ๊ธฐ</button>
<button class="btn" type="button" onclick="fn_reset()">๋ค์ํ๊ธฐ</button>
</td>
</tr>
</table>
</div>
</form>
</section>
<%@ include file="footer.jsp" %>
</body>
<script src="script.js"></script>
</html>
๋ฌธ์ ์์ ํ๋ฉด์ ๊ตฌ์ฑ์์๋ฅผ ์ ์ธํ ์คํ์ผ (ํ๋ฉด์ ์, ํฐํธ ๋ฑ)์ ์ ํ ์ฌํญ์ด๋ฏ๋ก ๋์์ธ์ ์ต๋ํ ๊ฐ๋จํ๊ฒ ๊ตฌํํฉ๋๋ค.
โmemberList.jsp (ํ๋ณด์กฐํ)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>memberList</title>
</head>
<body>
<%@ include file="topmenu.jsp" %>
<section>
<h2>โ ํ๋ณด์กฐํ โ</h2>
<div class="table">
<table style="width:700px;">
<tr>
<th>ํ๋ณด๋ฒํธ</th>
<th>์ฑ๋ช
</th>
<th>์์์ ๋น</th>
<th>ํ๋ ฅ</th>
<th>์ฃผ๋ฏผ๋ฒํธ</th>
<th>์ง์ญ๊ตฌ</th>
<th>๋ํ์ ํ</th>
</tr>
</table>
</div>
</section>
<%@ include file="footer.jsp" %>
</body>
</html>
โvoteList.jsp (ํฌํ๊ฒ์์กฐํ)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>voteList</title>
</head>
<body>
<%@ include file="topmenu.jsp" %>
<section>
<h2>โ ํฌํ๊ฒ์์กฐํ โ</h2>
<div class="table">
<table style="width:700px;">
<tr>
<th>์ฑ๋ช
</th>
<th>์๋
์์ผ</th>
<th>๋์ด</th>
<th>์ฑ๋ณ</th>
<th>ํ๋ณด๋ฒํธ</th>
<th>ํฌํ์๊ฐ</th>
<th>์ ๊ถ์ํ์ธ</th>
</tr>
</table>
</div>
</section>
<%@ include file="footer.jsp" %>
</body>
</html>
โvoteResult.jsp (ํ๋ณด์ ๋ฑ์)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>voteResult</title>
</head>
<body>
<%@ include file="topmenu.jsp" %>
<section>
<h2>โ ํ๋ณด์๋ฑ์ โ</h2>
<div class="table">
<table>
<tr>
<th>ํ๋ณด๋ฒํธ</th>
<th>์ฑ๋ช
</th>
<th>์ดํฌํ๊ฑด์</th>
</tr>
</table>
</div>
</section>
<%@ include file="footer.jsp" %>
</body>
</html>
์ด๋ ๊ฒ View ํ๋ฉด๋ถ๋ถ์ ๋ง๋ฌด๋ฆฌ ํ๊ฒ ์ต๋๋ค :D
๋ค์์๊ฐ (Step4. ๋ฐฑ์๋) ์๋ ๋ฐ์ดํฐ๋ฅผ ๋ถ๋ฌ์์ View ํ๋ฉด์ ์ถ๋ ฅ๋ ์์๊ฒ ํ๋๋ฐฉ๋ฒ์ ํฌ์คํ ํ๊ฒ ์ต๋๋ค ๐