fboardList.jsp - title 클릭
<td><!--fboardView.do로 이동 -->
<a href="fboardView.do?bno=${bBean.bno}">
${bBean.btitle}<c:if test="${bBean.bfile!=null }">
<span class="material-symbols-outlined">download
</span></c:if>
</a>
</td>
BController -"fboardView.do"
case "fboardView.do": //view 페이지
bservice=new BServiceSelectOne();
bservice.execute(request,response);
url="fboardView.jsp";
break;
✔BServiceSelectOne
BoardDao bdao = new BoardDao();
int bno=Integer.parseInt(request.getParameter("bno"));
//request.getParameter경우 String type이라 형변환 필요
BoardBean bBean=bdao.boardSelectOne(bno);
request.setAttribute("bBean", bBean);
✔BoardDao- boardSelectOne
try {
conn=getConn();
query="select * from freeboard where bno=?";
pstmt=conn.prepareStatement(query);
pstmt.setInt(1, bno2);
rs=pstmt.executeQuery();
while(rs.next()) {
bno=rs.getInt("bno");
bstep=rs.getInt("bstep");
bhit=rs.getInt("bhit");
bgroup=rs.getInt("bgroup");
bindent=rs.getInt("bindent");
id=rs.getString("id");
btitle=rs.getString("btitle");
bcontent=rs.getString("bcontent");
bfile=rs.getString("bfile");
bdate=rs.getTimestamp("bdate");
bBean=new BoardBean(bno, id, btitle, bcontent, bdate, bstep, bhit,bgroup, bindent, bfile);
} ~~(try catch문 뒷 부분 생략)
return bBean;
fboardView.jsp
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script>
function updateBtn(){
if(confirm("게시글을 수정하시겠습니까?"))location.href="fboardUpdate.do?bno="+${bBean.bno};
}
function deleteBtn(){
if(confirm("게시글을 삭제하시겠습니까?"))location.href="doFboardDelete.do?bno="+${bBean.bno};
}
</script>
<table>
<tr>
<th>제목</th>
<td>${bBean.btitle}</td>
</tr>
<tr>
<th>작성자</th>
<td>${bBean.id}</td>
</tr>
<tr>
<th>날짜</th>
<td>${bBean.bdate}</td>
</tr>
<tr>
<th>조회수</th>
<td>${bBean.bhit}</td>
</tr>
<tr id="content">
<th>내용</th>
<td>${bBean.bcontent}</td>
</tr>
<tr>
<th>파일명</th>
<td>
<!--첨부파일이 있다면 -->
<c:if test="${bBean.bfile!=null}">
<!--해당 첨부파일의 이름을 클릭하면 다운받을 수 있게 링크를 걸어줘라 -->
<a href="./upload/${bBean.bfile}"download>${bBean.bfile}</a>
</c:if>
<!--첨부파일이 없다면 파일없음이라고 보여줘라 -->
<c:if test="${bBean.bfile==null}">파일없음</c:if>
</td>
</tr>
<tr>
<th>첨부파일</th>
<td>
<!--첨부파일이 있다면 -->
<c:if test="${bBean.bfile!=null}">
<!--해당 첨부파일의 img를 보여줘라 -->
<img src="./upload/${bBean.bfile}">
</c:if>
<!--첨부파일이 없다면 파일없음이라고 보여줘라 -->
<c:if test="${bBean.bfile==null}">파일없음</c:if>
</td>
</tr>
</table>
<div>
<a href="fboardList.do"><button type="button">목록</button></a>
<button type="button" onclick="updateBtn()">수정</button></a>
<button type="button" onclick="deleteBtn()">삭제</button>
</div>

<자유게시판 View Page>