상세 컨텐츠

본문 제목

sts를 이용한 board 뷰들

JAVA/Spring

by 영공쁘이 2021. 8. 9. 17:51

본문

writeForm.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>writeForm.jsp</title>
<style type="text/css">
	h2{ text-align: center;}
	table{ margin: auto; background-color: ivory;}
</style>

<script src="//code.jquery.com/jquery-3.6.0.min.js"></script>  

<!-- 데이터 유효성 처리  jquery는 .val()이고 javascript는 .value이다.-->
<script>
 function check(){
		if($('#writer').val()=='')
			{
			alert("이름을 입력하시오");
			$('#writer').focus();
			return false;
			}
		if($('#subject').val()=='')
			{
			alert("글 제목을 입력하시오");
			$('#subject').focus();
			return false;
			}
		if($('#content').val()=='')
			{
			alert("글 내용을 입력하시오");
			$('#content').focus();
			return false;
			}
		if($('#pw').val()=='')
			{
			alert("암호를 입력하시오");
			$('#pw').focus();
			return false;
			}
		return true;
	} //check-end

</script>
</head>
<body>
	<c:if test="${num==0}">
		<h2>게시판 글쓰기</h2>
	</c:if>
	
	<c:if test="${num!=0}">
		<h2>답글 쓰기</h2>
	</c:if>
	
	<form method="POST" action="writePro.do" onsubmit="return check()">  <!-- onsubmit은 함수 호출 action은 거기로 가라 -->
		<input type="hidden" name="pageNum" value="${pageNum}">  <!-- 데이터를 감추며 보내고싶다! -->
		<input type="hidden" name="num" value="${num}">
		<input type="hidden" name="ref" value="${ref}">
		<input type="hidden" name="re_step" value="${re_step}">
		<input type="hidden" name="re_level" value="${re_level}">
		
		<table border="1">
			<tr>
				<td>이름</td>
				<td><input type="text" name="writer" id="writer" size="30"></td>
			</tr>
			
			<tr>
				<td>글제목</td>
				<td>
				<!-- 원글 -->
				<c:if test="${num==0}">
					<input type="text" name="subject" id="subject" size="40">
				</c:if>
				
				<!-- 답글 -->
				<c:if test="${num!=0}">
					<input type="text" name="subject" id="subject" size="40" value="[답변]">
				</c:if>
				</td>
			</tr>
			
			<tr>
				<td>글 내용</td>
				<td><textarea name="content" id="content" rows="10" cols="60"></textarea></td>
			</tr>
			
			
			<tr>
				<td>암호</td>
				<td><input type="password" name="pw" id="pw" size="20"></td>
			</tr>
			
			<tr>
				<td colspan="2" align="center">
					<!-- 글쓰기 -->
					<c:if test="${num==0}">
						<input type="submit" value="글쓰기">
					</c:if>
					<!-- 답변쓰기 -->
					<c:if test="${num!=0}">
						<input type="submit" value="답글쓰기">
					</c:if>
					
					<input type="reset" value="다시쓰기">
					<input type="button" value="글 목록" onClick="location.href='list.do'">
										
				</td>
			</tr>
		</table>
	</form>
	
</body>
</html>

 

'JAVA > Spring' 카테고리의 다른 글

형상관리 및 was  (0) 2021.08.24
Annotaion 총 정리(프로젝트에서 사용한 것 기준)  (0) 2021.08.17
sts를 이용한 member의 뷰 파일들  (0) 2021.08.09
Board관련 sts 코드  (0) 2021.08.09
Member 관련 sts 코드  (0) 2021.08.09

관련글 더보기