티스토리 뷰

list.jsp 수정했다.

일부러 jstl을 사용하지 않았다. 차근차근 하나하나 바꿔나가면서 jstl의 편리함을 보여줄 예정이다.

HTML도 TABLE을 사용하였고 DIV로 바꿔나갈 예정이다.

CSS부분도 TABLE태그 안에 인라인 방식으로 작성했다. CSS부분만 따로 분리하여 바꿔나갈 예정.

디자인 감각은 엄청나게 없으므로 지금은 그냥 게시글 목록들을 정상적으로 출력해주는구나 정도로만 봐주길 바란다.


<%@page import="java.text.SimpleDateFormat"%>

<%@page import="sjb.board.dao.SJBoardDTO"%>

<%@page import="java.util.ArrayList"%>

<%@page import="sjb.board.dao.SJBoardDAO"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ page import="sjb.board.*" %>

<%@ page import="java.util.*" %>

<%

//리플렉션(커넥션생성)

SJBoardDAO sjBoardDao =  SJBoardDAO.newInstance();

//rowSize설정 한페이지에 보여줄 게시글 갯수

int rowSize = 10;

int start = 0;

//현재페이지 설정 및 예외처리(null값 또는 0일때 1로 처리)

String strPage = request.getParameter("page");

if(strPage == null || strPage == "0")strPage = "1";

//DAO에 현재페이지 정보를 넘기기위해 Integer로 형변환

int curPage = Integer.parseInt(strPage);

//검색 조건 및 검색어 변수 선언

String strFs = request.getParameter("fs");

String strSs = request.getParameter("ss");

//시작 페이지, 마지막 페이지 변수 선언 && 예외처리 (null값 또는 0일때) 

String strStart = request.getParameter("start");

if(strStart == null || strStart == "0")start = 1;

else{

start = (curPage * rowSize) - (rowSize - 1);

}

int end = curPage * rowSize;

//총 게시글 갯수

int totalBoardCount = sjBoardDao.getTotalBoardCount();

//총 페이지 구하기

int allPage = (int)(Math.ceil(totalBoardCount / (double)rowSize));

//페이지 블락 설정

int blockPage = 10;

//페이지 블락 구간 시작페이지 설정

int fromPageBlock = ((curPage-1) / blockPage * blockPage + 1);

int toPageBlock = ((curPage - 1) / blockPage * blockPage) + blockPage;

//마지막 페이지 예외처리

if(toPageBlock > allPage)toPageBlock = allPage;

//게시글 목록 갖고오기

ArrayList<SJBoardDTO> sjBoardDto = sjBoardDao.boardList(curPage, start, end, strFs, strSs);

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>

<table width="600" height="330" border="1">

<tr height="10%">

<td width="10%">번호</td>

<td width="45%">제목</td>

<td width="15%">작성자</td>

<td width="20%">작성일</td>

<td width="10%">조회수</td>

</tr>

<%

String color = "white";

for(int i=0;i<sjBoardDto.size();i++){

SJBoardDTO sjbDTO = sjBoardDto.get(i);

if(i%2 == 0)color = "ivory";

else color = "white";

%>

<tr height="10%" bgcolor="<%=color%>">

<td width="10%"><%=sjbDTO.getNo() %></td>

<td width="45%"><%=sjbDTO.getSubject() %></td>

<td width="15%"><%=sjbDTO.getName() %></td>

   //작성일에 대해서는 Date클래스를 이용하여 사용하면 좋은데 우선 이렇게 작성했다.

<td><%=sjbDTO.getRegdate() %></td>

<td><%=sjbDTO.getReadnum() %></td>

</tr>

<%

}

%>

</table>

</body>

</html>

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함