1. web에 list.jsp 생성
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>상품리스트 보기</title>
</head>
<body>
<h1>상품리스트보기 Product List Page</h1>
<table border="1">
<thead>
<tr>
<th>번호 pno</th>
<th>이름 pname</th>
<th>등록일자 regdate</th>
</tr>
</thead>
<tbody>
<c:forEach items="${list }" var="pvo">
<tr>
<td>${pvo.pno }</td>
<td><a href="detail.pd">${pvo.pname }</a></td>
<td>${pvo.regdate }</td>
</tr>
</c:forEach>
</tbody>
</table>
<!-- 이동 버튼 -->
<a href="register.pd"><button type="button">상품등록</button></a>
<a href="index.pd"><button type="button">index</button></a>
</body>
</html>
2. ProductController에 case "/list.pd" 추가
이제 list밑줄을 눌러가면서 register-insert만드는 것처럼 계속 만들기 진행..
https://jungeun980906.tistory.com/318
@Override
public List<productVO> selectList() {
// 전체출력
System.out.println(">>> DAO 접속 완료 ");
query = "select * from product order by pno desc;"; //pno기준 내림차순 = 신상부터
List<productVO> list = new ArrayList<productVO>();
try {
pst = conn.prepareStatement(query);
ResultSet re = pst.executeQuery();
while(re.next()) {
list.add(new productVO(re.getInt("pno"),
re.getString("pname"),
re.getString("regdate"))); //안에 들어가는 "pno"는 db안의 이름!
}
return list;
} catch (SQLException e) {
System.out.println("출력 에러");
e.printStackTrace();
}
return null;
}
출력 화면
'JSP > JSP' 카테고리의 다른 글
[jsp] 7. modify 제품 수정 페이지 만들기 (0) | 2023.05.11 |
---|---|
[jsp] 6. detail 제품상세페이지 만들기 (0) | 2023.05.11 |
[jsp] 4. insert 상품DB에 등록하기 (register에서 추가버튼 클릭시) (0) | 2023.05.11 |
[jsp] 2. ProductController 만들기! (product 연결) (0) | 2023.05.11 |
[jsp] 3. register 등록하는 페이지 만들기 (0) | 2023.05.11 |