JSP - Maven - Board (Show Detail)

화이티 ·2023년 12월 21일
0

JSP

목록 보기
4/12

Board detail

<!-- Q19. 게시글 세부내용 조회 기능 -->	
			<%
			
			//num: 게시글을 식별할 수 있는 고유 번호
		int num=	Integer.parseInt(request.getParameter("num"));
			Board board =	new BoardDAO().detailBoard(num);		
				%>
			<div id = "board">
				<table id="list">
					<tr>
						<td>제목</td>
						<td><%=board.getTitle() %></td>
					</tr>
					<tr>
						<td>작성자</td>
						<td><%=board.getWriter() %></td>
					</tr>
					
					<tr>
					<td>다운로드</td>
					<td><a href = "./file/<%=board.getFilename()%>" download ><%=board.getFilename() %></a></td>
					</tr>
					<tr>
						<td colspan="2">내용</td>
						
					</tr>
					<tr>
						<td colspan="2">
							<h3><%=board.getContent() %></h3>
							<img alt ="" src = "./file/<%=board.getFilename()%>">
						</td>
					</tr>
					<tr>
						<td colspan="2"><a href="BoardMain.jsp"><button>뒤로가기</button></a></td>
					</tr>
				</table>

BoardDAO

public Board detailBoard(int num) {
	Board board =null;
	try {
		board = sqlSession.selectOne("com.smhrd.database.BoardMapper.detailBoard",num);
	}catch (Exception e) {
		e.printStackTrace();
	}finally {
		sqlSession.close();
	}
	return board;
}

BoardMapper

<select id ="detailBoard"  resultType ="Board" >
select * from web_board1 where num =#{num} 
</select>
profile
열심히 공부합시다! The best is yet to come! 💜

0개의 댓글