SMALL
안녕하세요, 코린이의 코딩 학습기 채니 입니다.
개인 포스팅용으로 내용에 오류 및 잘못된 정보가 있을 수 있습니다.
게시판 페이지 구현 준비
header.jsp
<li class="board"><a href="<%=request.getContextPath()%>/board/boardList">게시판</a></li>
클래스 구조
DB
-- 게시판 | 첨부파일 테이블
create table board (
no number,
title varchar2(500) not null,
writer varchar2(20),
content varchar2(4000) not null,
read_count number default 0,
reg_date date default sysdate,
constraint pk_board_no primary key(no),
constraint fk_board_writer foreign key(writer) references member(member_id) on delete set null
);
create sequence seq_board_no;
create table attachment (
no number,
board_no number not null,
original_filename varchar2(255) not null, -- 업로드한 파일명 (중복된 파일 덮어쓰기 방지용, 보안문제, 인코딩 오류 유발 방지)
rename_filename varchar2(255) not null, -- 실제 저장된 파일명
reg_date date default sysdate,
constraint pk_attachment_no primary key(no),
constraint fk_attachment_board_no foreign key(board_no) references board(no) on delete cascade
);
alter table attachment rename column rename_filename to renamed_filename;
create sequence seq_attachment_no;
comment on column board.no is '게시글번호';
comment on column board.title is '게시글제목';
comment on column board.writer is '게시글작성자 아이디';
comment on column board.content is '게시글내용';
comment on column board.read_count is '조회수';
comment on column board.reg_date is '게시글작성일시';
comment on column attachment.no is '첨부파일번호(PK)';
comment on column attachment.board_no is '게시판글번호(FK)';
comment on column attachment.original_filename is '업로드한 첨부파일명';
comment on column attachment.renamed_filename is '서버에 저장된 첨부파일명';
comment on column attachment.reg_date is '첨부파일업로드일시';
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 1','honggd','반갑습니다',to_date('18/02/10','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 2','qwerty','안녕하세요',to_date('18/02/12','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 3','admin','반갑습니다',to_date('18/02/13','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 4','honggd','안녕하세요',to_date('18/02/14','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 5','qwerty','반갑습니다',to_date('18/02/15','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 6','admin','안녕하세요',to_date('18/02/16','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 7','honggd','반갑습니다',to_date('18/02/17','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 8','qwerty','안녕하세요',to_date('18/02/18','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 9','admin','반갑습니다',to_date('18/02/19','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 10','honggd','안녕하세',to_date('18/02/20','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 11','qwerty','반갑습니다',to_date('18/03/11','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 12','admin','안녕하세',to_date('18/03/12','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 13','honggd','반갑습니다',to_date('18/03/13','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 14','qwerty','안녕하세',to_date('18/03/14','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 15','admin','반갑습니다',to_date('18/03/15','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 16','honggd','안녕하세',to_date('18/03/16','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 17','qwerty','반갑습니다',to_date('18/03/17','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 18','admin','안녕하세',to_date('18/03/18','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 19','honggd','반갑습니다',to_date('18/03/19','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 20','qwerty','안녕하세',to_date('18/03/20','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 21','admin','반갑습니다',to_date('18/04/01','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 22','honggd','안녕하세',to_date('18/04/02','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 23','qwerty','반갑습니다',to_date('18/04/03','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 24','admin','안녕하세',to_date('18/04/04','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 25','honggd','반갑습니다',to_date('18/04/05','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 26','qwerty','안녕하세',to_date('18/04/06','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 27','admin','반갑습니다',to_date('18/04/07','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 28','honggd','안녕하세',to_date('18/04/08','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 29','qwerty','반갑습니다',to_date('18/04/09','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 30','admin','안녕하세',to_date('18/04/10','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 31','honggd','반갑습니다',to_date('18/04/16','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 32','qwerty','안녕하세',to_date('18/04/17','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 33','admin','반갑습니다',to_date('18/04/18','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 34','honggd','안녕하세',to_date('18/04/19','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 35','qwerty','반갑습니다',to_date('18/04/20','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 36','admin','안녕하세',to_date('18/05/01','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 37','honggd','반갑습니다',to_date('18/05/02','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 38','qwerty','안녕하세',to_date('18/05/03','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 39','admin','반갑습니다',to_date('18/05/04','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 40','honggd','안녕하세',to_date('18/05/05','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 41','qwerty','반갑습니다',to_date('18/05/06','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 42','admin','안녕하세',to_date('18/05/07','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 43','honggd','반갑습니다',to_date('18/05/08','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 44','qwerty','안녕하세',to_date('18/05/09','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 45','admin','반갑습니다',to_date('18/05/10','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 46','honggd','안녕하세',to_date('18/05/16','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 47','qwerty','반갑습니다',to_date('18/05/17','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 48','admin','안녕하세',to_date('18/05/18','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 49','honggd','반갑습니다',to_date('18/05/19','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 50','qwerty','안녕하세',to_date('18/05/20','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 51','admin','반갑습니다',to_date('18/05/01','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 52','honggd','안녕하세',to_date('18/06/02','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 53','qwerty','반갑습니다',to_date('18/06/03','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 54','admin','안녕하세',to_date('18/06/04','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 55','honggd','반갑습니다',to_date('18/06/05','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 56','qwerty','안녕하세',to_date('18/06/06','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 57','admin','반갑습니다',to_date('18/06/07','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 58','honggd','안녕하세',to_date('18/06/08','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 59','qwerty','반갑습니다',to_date('18/06/09','RR/MM/DD'),0);
insert into web2.board (no,title,writer,content,reg_date,read_count) values (seq_board_no.nextval,'안녕하세요, 게시판입니다 - 60','admin','안녕하세',to_date('18/06/10','RR/MM/DD'),0);
insert into web2.attachment(no, board_no, original_filename, renamed_filename)
values(seq_attachment_no.nextval, 60, 'test.txt', '20211007_233014432_12345.txt');
첨부파일은 업로드한 파일명/실제 파일명을 나눠서 컬럼을 생성하였는데, 그 이유는 중복된 파일 덮어쓰기 방지용, 보안문제, 인코딩 오류 유발 방지를 위해서 입니다.
Dto
Board
public class Board {
private int no;
private String title;
private String writer;
private String content;
private int readCount;
private Timestamp regDate;
public Board() {
super();
// TODO Auto-generated constructor stub
}
public Board(int no, String title, String writer, String content, int readCount, Timestamp regDate) {
super();
this.no = no;
this.title = title;
this.writer = writer;
this.content = content;
this.readCount = readCount;
this.regDate = regDate;
}
// getter, setter 생략
@Override
public String toString() {
return "Board [no=" + no + ", title=" + title + ", writer=" + writer + ", content=" + content + ", readCount="
+ readCount + ", regDate=" + regDate + "]";
}
}
Attachment
public class Attachment {
private int no;
private int boardNo;
private String originalFilename;
private String renamedFilename;
private Timestamp regDate;
public Attachment() {
super();
// TODO Auto-generated constructor stub
}
public Attachment(int no, int boardNo, String originalFilename, String renamedFilename, Timestamp regDate) {
super();
this.no = no;
this.boardNo = boardNo;
this.originalFilename = originalFilename;
this.renamedFilename = renamedFilename;
this.regDate = regDate;
}
// getter, setter
@Override
public String toString() {
return "Attachment [no=" + no + ", boardNo=" + boardNo + ", originalFilename=" + originalFilename
+ ", renamedFilename=" + renamedFilename + ", regDate=" + regDate + "]";
}
}
boardList.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/common/header.jsp" %>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/board.css" />
<section id="board-container">
<h2>게시판 </h2>
<table id="tbl-board">
<tr>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
<th>작성일</th>
<th>첨부파일</th><%--첨부파일이 있는 경우 /images/file.png 표시 width:16px --%>
<th>조회수</th>
</tr>
</table>
<div id='pagebar'></div>
</section>
<%@ include file="/WEB-INF/views/common/footer.jsp" %>
css
board.css
@CHARSET "UTF-8";
/*게시판*/
section#board-container{width:600px; margin:0 auto; text-align:center;}
section#board-container h2{margin:10px 0;}
table#tbl-board{width:100%; margin:0 auto; border:1px solid black; border-collapse:collapse; clear:both; }
table#tbl-board th, table#tbl-board td {border:1px solid; padding: 5px 0; text-align:center;}
/*글쓰기버튼*/
input#btn-add{float:right; margin: 0 0 15px;}
/*페이지바*/
div#pagebar{margin-top:10px; text-align:center; background-color:rgba(0, 188, 212, 0.3); }
div#pagebar span.cPage{color: #0066ff; margin-right: 5px;}
div#pagebar a{margin-right: 5px;}
/*게시글 작성/상세보기 테이블*/
table#tbl-board-view {
width:500px;
margin:0 auto;
border:1px solid black;
border-collapse:collapse;
}
table#tbl-board-view th {
width: 150px;
border:1px solid;
padding: 10px 0;
text-align:center;
}
table#tbl-board-view td {
border:1px solid;
padding: 5px 0 5px 15px;
text-align:left;
}
table#tbl-board-view img {width: 16px;}
table#tbl-board-view input[type=file] {margin: 3px 0;}
/*게시글 수정하기*/
span#fname{
position: absolute;
left: 92px;
top: 10px;
width: 255px;
font-size: 14px;
background: #f5f5f5;
}
#del_file+label{font-size:.8em; position:relative; top:-3px;}
/*댓글등록버튼*/
div.comment-container button#btn-comment-enroll1 {width:60px; height:50px; color:white; background:#3300ff; position:relative; top:-20px;}
/*댓글테이블*/
table#tbl-comment{width:580px; margin:0 auto; border-collapse:collapse;}
table#tbl-comment tr td{border-bottom:1px solid; border-top:1px solid; padding:5px; text-align:left; line-height:120%;}
table#tbl-comment tr td:first-of-type{padding: 5px 5px 5px 50px;}
table#tbl-comment tr td:last-of-type {text-align:right; width: 100px;}
table#tbl-comment button.btn-reply{display:none;}
table#tbl-comment tr:hover {background:lightgray;}
table#tbl-comment tr:hover button.btn-reply{display:inline;}
table#tbl-comment sub.comment-writer {color:navy; font-size:14px}
table#tbl-comment sub.comment-date {color:tomato; font-size:10px}
table#tbl-comment tr.level2 {color:gray; font-size: 14px;}
table#tbl-comment tr.level2 td:first-of-type{padding-left:100px;}
table#tbl-comment tr.level2 sub.comment-writer {color:#8e8eff; font-size:14px}
table#tbl-comment tr.level2 sub.comment-date {color:#ff9c8a; font-size:10px}
/*답글관련*/
table#tbl-comment textarea{margin: 4px 0 0 0;}
table#tbl-comment button.btn-comment-enroll2{width:60px; height:23px; color:white; background:#3300ff; position:relative; top:-5px; left:10px;}
/* 삭제버튼관련 */
table#tbl-comment button.btn-delete{background:red; color:white; display:none;}
table#tbl-comment tr:hover button.btn-delete{display:inline;}
게시판 페이지 구현 및 페이징 처리
Controller
BoardListServlet
public class BoardListServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private BoardService boardService = new BoardService();
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
// 1. 사용자입력값
int cPage = 1;
int numPerPage = 5;
try {
cPage = Integer.parseInt(request.getParameter("cPage"));
} catch(NumberFormatException e) {}
// 2. 업무로직
// a. content 영역
int start = (cPage - 1) * numPerPage + 1;
int end = cPage * numPerPage;
Map<String, Object> param = new HashMap<>();
param.put("start", start);
param.put("end", end);
List<Board> boardList = boardService.findAll(param);
// b. pagebar영역
int totalContent = boardService.getTotalContent();
String url = request.getRequestURI();
String pagebar = HelloMvcUtils.getPagebar(cPage, numPerPage, totalContent, url);
// 3. view단 처리
request.setAttribute("boardList", boardList);
request.setAttribute("pagebar", pagebar);
request.getRequestDispatcher("/WEB-INF/views/board/boardList.jsp").forward(request, response);
} catch(Exception e) {
e.printStackTrace();
throw e;
}
}
}
Service
BoardService
public class BoardService {
private BoardDao boardDao = new BoardDao();
public List<Board> findAll(Map<String, Object> param) {
Connection conn = getConnection();
List<Board> boardList = boardDao.findAll(conn, param);
close(conn);
return boardList;
}
public int getTotalContent() {
Connection conn = getConnection();
int totalContent = boardDao.getTotalContent(conn);
close(conn);
return totalContent;
}
}
Dao
BoardDao
public class BoardDao {
private Properties prop = new Properties();
public BoardDao() {
String filename = BoardDao.class.getResource("/sql/board/board-query.properties").getPath();
System.out.println("filename = " + filename);
try {
prop.load(new FileReader(filename));
} catch (IOException e) {
e.printStackTrace();
}
}
// findAll = select * from (select row_number () over (order by no desc) rnum, b.* from board b) b where rnum between ? and ?
public List<Board> findAll(Connection conn, Map<String, Object> param) {
PreparedStatement pstmt = null;
ResultSet rset = null;
List<Board> boardList = new ArrayList<>();
String sql = prop.getProperty("findAll");
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, (int)param.get("start"));
pstmt.setInt(2, (int)param.get("end"));
rset = pstmt.executeQuery();
while(rset.next()) {
boardList.add(handleBoardResultSet(rset));
}
} catch (SQLException e) {
throw new BoardException("게시글 전체 조회 오류!", e);
} finally {
close(rset);
close(pstmt);
}
return boardList;
}
// getTotalContent = select count(*) from board
public int getTotalContent(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rset = null;
int totalContent = 0;
String sql = prop.getProperty("getTotalContent");
try {
pstmt = conn.prepareStatement(sql);
rset = pstmt.executeQuery();
if(rset.next()) {
totalContent = rset.getInt(1);
}
} catch (SQLException e) {
throw new BoardException("전체 게시글 수 조회 오류!", e);
} finally {
close(rset);
close(pstmt);
}
return totalContent;
}
private Board handleBoardResultSet(ResultSet rset) throws SQLException {
int no = rset.getInt("no");
String title = rset.getString("title");
String writer = rset.getString("writer");
String content = rset.getString("content");
int readCount = rset.getInt("read_count");
Timestamp regDate = rset.getTimestamp("reg_date");
return new Board(no, title, writer, content, readCount, regDate);
}
}
boardList.jsp
<%@page import="com.ce.mvc2.board.model.dto.Board"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/common/header.jsp" %>
<%
List<Board> boardList = (List<Board>)request.getAttribute("boardList");
%>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/board.css" />
<section id="board-container">
<h2>게시판 </h2>
<table id="tbl-board">
<tr>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
<th>작성일</th>
<th>첨부파일</th><%--첨부파일이 있는 경우 /images/file.png 표시 width:16px --%>
<th>조회수</th>
</tr>
<% if(boardList != null && !boardList.isEmpty()) {
for(Board board : boardList) { %>
<tr>
<td><%= board.getNo() %></td>
<td><%= board.getTitle() %></td>
<td><%= board.getWriter() %></td>
<td><%= new SimpleDateFormat("yyyy-MM-dd HH:mm").format(board.getRegDate()) %></td>
<td></td>
<td><%= board.getReadCount() %></td>
</tr>
<% }
} else { %>
<tr>
<td colspan="6">조회된 게시글이 없습니다.</td>
</tr>
<% } %>
</table>
<div id='pagebar'>
<%= request.getAttribute("pagebar") %>
</div>
</section>
<%@ include file="/WEB-INF/views/common/footer.jsp" %>
※ HelloMvcUtils.getPagebar() 메소드 관련 포스팅
https://chanychu.tistory.com/324?category=980487
LIST
'Java > Servlet & JSP' 카테고리의 다른 글
JSP) 첨부파일이 포함된 게시글 등록 - 첨부파일 처리 (0) | 2022.07.03 |
---|---|
JSP) 첨부파일 있는 게시글 표시 (0) | 2022.07.02 |
JSP) 관리자 권한 변경 - Referer, dataset (0) | 2022.07.02 |
JSP) 검색 페이징 처리 (0) | 2022.07.01 |
JSP) 검색기능 구현하기 (0) | 2022.07.01 |