๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IT์ž๊ฒฉ์ฆ ๊ณต๋ถ€/์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ์‹ค๊ธฐ

[์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ๊ณผ์ •ํ‰๊ฐ€ํ˜• ์‹ค๊ธฐ] ์ง€์—ญ๊ตฌ์˜์›ํˆฌํ‘œ - View ํ™”๋ฉด

by yunamom 2022. 4. 27.
728x90
300x250

๊ตฌํ˜„ ์ˆœ์„œ ( ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๐Ÿ‘‰๐Ÿป ์„œ๋ฒ„ ๐Ÿ‘‰๐Ÿป ํ”„๋ก ํŠธ ๐Ÿ‘‰๐Ÿป ๋ฐฑ์—”๋“œ )

 

1) [์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ๊ณผ์ •ํ‰๊ฐ€ํ˜•] ์‹ค๊ธฐ์‹œํ—˜ ๋ฌธ์ œ - ์ง€์—ญ๊ตฌ์˜์›ํˆฌํ‘œ

2) [์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ๊ณผ์ •ํ‰๊ฐ€ํ˜•] ์‹ค๊ธฐ MVC ํŒจํ„ด ๊ตฌ์กฐ / ํ๋ฆ„

3) [์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ๊ณผ์ •ํ‰๊ฐ€ํ˜•] ์ง€์—ญ๊ตฌ์˜์›ํˆฌํ‘œ - DB ์ƒ์„ฑํ•˜๊ธฐ
4) [์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ๊ณผ์ •ํ‰๊ฐ€ํ˜•] ์ง€์—ญ๊ตฌ์˜์›ํˆฌํ‘œ - Java / Servlet ์ƒ์„ฑ
5) [์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ๊ณผ์ •ํ‰๊ฐ€ํ˜•] ์ง€์—ญ๊ตฌ์˜์›ํˆฌํ‘œ - View ํ™”๋ฉด ๋งŒ๋“ค๊ธฐ
6) [์ •๋ณด์ฒ˜๋ฆฌ์‚ฐ์—…๊ธฐ์‚ฌ ๊ณผ์ •ํ‰๊ฐ€ํ˜•] ์ง€์—ญ๊ตฌ์˜์›ํˆฌํ‘œ - ๋ฐ์ดํ„ฐ ์ž…/์ถœ๋ ฅ

โœจ Step3. View ํ™”๋ฉด ๋งŒ๋“ค๊ธฐ ( JSP ํŒŒ์ผ ์ƒ์„ฑ) 

 

  1. topmenu.jsp (<header>, <nav>)
  2. footer.jsp (<footer>)
  3. index.jsp (ํ™ˆ์œผ๋กœ)
  4. memberList.jsp (ํ›„๋ณด์กฐํšŒ)
  5. voteMember.jsp (ํˆฌํ‘œํ•˜๊ธฐ)
  6. voteList.jsp (ํˆฌํ‘œ๊ฒ€์ˆ˜์กฐํšŒ)
  7. voteResult.jsp (ํ›„๋ณด์ž ๋“ฑ์ˆ˜)
  8. style.css
  9. 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 ํ™”๋ฉด์— ์ถœ๋ ฅ๋ ์ˆ˜์žˆ๊ฒŒ ํ•˜๋Š”๋ฐฉ๋ฒ•์„ ํฌ์ŠคํŒ…ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ๐Ÿ˜Š

 

728x90
300x250

์ฝ”๋“œ