- BoardBean.java, BoardDao.java 소스는 17일차 프로젝트 파일과 동일
- web.xml 소스
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<jsp-config>
<taglib>
<taglib-uri>
/WEB-INF/tlds/el-fun.tld
</taglib-uri>
<taglib-location>
/WEB-INF/tlds/el-fun.tld
</taglib-location>
</taglib>
</jsp-config>
</web-app>
- el-fun.tld 소스
<?xml version="1.0" encoding="euc-kr"?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<description>EL에서 함수실행</description>
<tlib-version>1.0</tlib-version>
<short-name>ELfunctions</short-name>
<uri>/ELFunctions</uri>
<function>
<description> 모든 게시물 가져오기 </description>
<name> getAll </name>
<function-class> Jstl.GetAllBoard </function-class>
<function-signature>Vector getAll(int, int)</function-signature>
</function>
</taglib>
- BoardList.jsp 소스
<%@page import="java.util.Vector"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="oper" uri="/WEB-INF/tlds/el-fun.tld"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<center>
<h2> 게 시 판 목 록 </h2>
<form action = "BoardWrite.jsp" method = "post">
<table border = "1" width = "740" cellpadding="4" cellspacing="2">
<tr bgcolor = "FFFFFFF">
<th width = "50"> 번호 </th>
<th width = "330"> 제목 </th>
<th width = "130"> 작성자 </th>
<th width = "130"> 날짜 </th>
<th width = "80"> 조회수 </th>
</tr>
<c:forEach var="bean" items="${oper:getAll(1, 10)}">
<tr>
<td width = "50"> ${bean.getNum()} </td>
<td width = "330"> ${bean.getSubject()} </td>
<td width = "130"> ${bean.getWriter()} </td>
<td width = "130"> ${bean.getReg_date()} </td>
<td width = "80"> ${bean.getReadcount()} </td>
</tr>
</c:forEach>
</table>
</form>
</center>
</body>
</html>
- GetAllBoard.java 소스
package Jstl;
import java.util.Vector;
public class GetAllBoard {
// Vector에서 <>를 안써줘야됨.
public static Vector getAll(int start, int end){
Vector<BoardBean> v = null;
BoardDao bdao = new BoardDao();
v = bdao.getAllBoard(start, end);
return v;
}
}
- 결과