반응형
게시판 목록에서 "제목"을 클릭했을 때 글의 내용을 확인할 수 있는 페이지를 구현한다. 따라서, DdaDAO에 글을 불러오는 함수를 추가한다.
DdaDAO.java
public Dda getDda(int ddaID) {
String SQL="SELECT * from DDA where ddaID = ?";
try {
PreparedStatement pstmt=conn.prepareStatement(SQL);
pstmt.setInt(1, ddaID);
rs=pstmt.executeQuery();
if(rs.next()) {
Dda dda = new Dda();
dda.setDdaID(rs.getInt(1));
dda.setDdaTitle(rs.getString(2));
dda.setUserID(rs.getString(3));
dda.setDdaDate(rs.getString(4));
dda.setDdaContent(rs.getString(5));
dda.setDdaAvailable(rs.getInt(6));
return dda;
}
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
view.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.io.PrintWriter" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name ="viewport" content="width=device-width", initial-scale="1">
<link rel="stylesheet" href="css/bootstrap.css">
<title>JSP 게시판 웹 사이트</title>
</head>
<body>
<%
String userID=null;
if(session.getAttribute("userID")!=null){
userID=(String)session.getAttribute("userID");
}
%>
<nav class="navbar navbar-inverse">
<div class ="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"
aria-expanded="false">
<span class ="icon-bar"></span>
<span class ="icon-bar"></span>
<span class ="icon-bar"></span>
</button>
<a class="navbar-brand" href="main.jsp">JSP 게시판 웹 사이트</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="main.jsp">메인</a></li>
<li class="active"><a href="dda.jsp">게시판</a></li>
</ul>
<%
if(userID==null){//로그인이 되어 있지 않다면
%>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle"
data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">접속하기<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="login.jsp">로그인</a></li>
<li><a href="join.jsp">회원가입</a></li>
</ul>
</li>
</ul>
<%
} else{//로그인이 되어있다면
%>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle"
data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">회원관리<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="logoutAction.jsp">로그아웃</a></li>
</ul>
</li>
</ul>
<%
}
%>
</div>
</nav>
<div class="container">
<div class="row">
<form method="post" action="writeAction.jsp">
<table class="table table-striped" style="text-align: center; border: 1px solid #dddddd">
<thead>
<tr>
<th colspan="2" style="background-color: #1BBC9B; text-align:center;">게시판 글쓰기 양식</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" class="form-control" placeholder="글 제목" name="ddaTitle" maxlength="50"></td>
</tr>
<tr>
<td><textarea class="form-control" placeholder="글 내용" name="ddaContent" maxlength="2048" style="height: 350px"></textarea></td>
</tr>
</tbody>
</table>
<input type="submit" class="btn btn-success pull-right" value="글쓰기">
</form>
</div>
</div>
<script src="http://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
반응형
'CodeSiri > Project' 카테고리의 다른 글
[Googoos🕊] 01. Spring | Spring Security 회원가입/로그인/로그아웃 (0) | 2021.05.14 |
---|---|
[Mini Project 🚴🏻♀️] 12. 게시글 수정 및 삭제 기능 구현 & 회고 (0) | 2021.02.22 |
[Mini Project 🚴🏻♀️] 10. 게시판 글 목록 기능 구현 (0) | 2021.02.22 |
[Mini Project 🚴🏻♀️] 09. 글쓰기 기능 구현 (0) | 2021.02.22 |
[Mini Project 🚴🏻♀️] 08. 게시판 데이터베이스 구축하기 (0) | 2021.02.22 |