[1. DB 테이블 만들기]
CREATE TABLE `smart`.`board` (
`num` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NOT NULL,
`content` TEXT NULL,
`writer` VARCHAR(25) NULL,
`writerDate` DATETIME NULL,
PRIMARY KEY (`num`));
[2. 페이지 준비]
- board.jsp
//게시판에 대해선 따로 말이 없었다.
//글쓰기 페이지로 넘어가면 되므로 버튼만 만들고 넘긴다.
<body>
<p>게시판</p>
<hr>
<button onclick="location.href='writer.jsp'">글쓰기</button>
</body>
- writer.jsp
//작성된 값은 post 방식으로 넘기고 writerAct.jsp에서 DB연결 및 쿼리문을 작성한다.
<body>
<form method="post" action="writerAct.jsp">
제목: <input name="title" id="title">
<br>
내용: <textarea name="content" id="content"></textarea>
<br>
작성자: <input name="writer" id="writer"><br>
<button type="submit" id="submit">글쓰기</button>
</form>
</body>
- list.jsp
//스크립틀릿을 담는 행을 반복시켜줘야 함을 기억한다.
<thead>
<tr>
<th>글번호</th>
<th>제목</th>
<th>작성자</th>
<th>작성날짜</th>
</tr>
</thead>
<tbody>
<!-- 반복이 시작되어야 하는 행 -->
<tr>
<!-- 내용입력 값에 스크립틀릿이 들어가야 한다. -->
<!-- 제목 클릭 시 상세내용 페이지로 이동한다. -->
<td>번호입력</td>
<td><a href="#">근두운</a></td>
<td>손오공</td>
<td>2022-05-06</td>
</tr>
</tbody>
- update.jsp
<!-- bootstrapk cdn 3줄 받아옴 -->
<form method="post" action="updateAct.jsp">
<!-- name값을 받아야 하며, num으로 받는다. -->
<!-- num = pk이기도 하기에 수정하고자 하는 글의 내용값만 받아서 수정할 수 있게 한다. -->
<input type="hidden" name="num" value="">
<table class="table">
<tr>
<th>제목:</th>
<!-- value=넘어올 값 -->
<td><input class="form-control" name="title" id="title" value=""></td>
</tr>
<tr>
<th>내용:</th>
<td><textarea class="form-control" name="content" id="content"><!-- 넘어올 값 --></textarea></td>
</tr>
<tr>
<th>작성자:</th>
<!-- value=넘어올 값 -->
<td><input class="form-control" name="writer" id="writer" value=""></td>
</tr>
</table>
<div class="pull-right"><button class="btn btn-default" type="submit" id="submit">글쓰기</button></div>
</form>
'jsp > 숙제' 카테고리의 다른 글
[error] (0) | 2022.05.12 |
---|---|
게시판 만들기 (1) (0) | 2022.05.10 |
0429 ~ (0) | 2022.04.29 |