240123 게시판 만들기(방문흔적 찾아가기)
2024. 1. 23. 09:53ㆍ2023.11.21-2024.05.31
myInfo.jsp - 방문흔적찾아가기 추가하기
<h2>방문흔적찾아가기</h2>
<table>
<thead>
<tr>
<td>번호</td>
<td>글번호</td>
<td>글제목</td>
<td>읽은 날짜</td>
</tr>
</thead>
<tbody>
<c:forEach items="${readData }" var="d">
<tr>
<td>${d.vno }</td>
<td>${d.board_no }</td>
<td>${d.mno }</td>
<td>${d.vdate }</td>
</tr>
</c:forEach>
</tbody>
</table>
</article>
MyInfo.java 추가하기
//2024-01-23
List<Map<String, Object>> readData = dao.readData(dto);
request.setAttribute("readData",readData);
System.out.println("readData: " + readData);
RequestDispatcher rd = request.getRequestDispatcher("myInfo.jsp");
rd.forward(request, response);
} else {
response.sendRedirect("./login");
}
MemberDAO.java
// 2024.01.23
public List<Map<String, Object>> readData(MemberDTO dto) {
List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
Connection conn = db.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "SELECT * FROM visitcount WHERE mno=(SELECT mno FROM member WHERE mid=?)";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, dto.getMid());
rs = pstmt.executeQuery();
// 한개면 IF, 여러개면 WHILE
while (rs.next()) {
Map<String, Object> e = new HashMap<String, Object>();
e.put("vno", rs.getInt("vno"));
e.put("board_no", rs.getInt("board_no"));
e.put("mno", rs.getInt("mno"));
e.put("vdate", rs.getString("vdate"));
data.add(e);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
close(rs, pstmt, conn);
}
return data;
}
}
'2023.11.21-2024.05.31' 카테고리의 다른 글
240124 게시판 만들기(댓글창 삭제, 수정) (1) | 2024.01.24 |
---|---|
240123 게시판 만들기(ip 띄우기 /log) (0) | 2024.01.23 |
기록 (0) | 2024.01.20 |
240118 join.jsp, Join.java, IDcheck.java 만들기 (0) | 2024.01.18 |
쿼리2 (0) | 2024.01.15 |