본문 바로가기

2023.11.21-2024.05.31

240102 HTML index.jsp

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<%@page import="com.sukgi.dao.BoardDAO"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="org.mariadb.jdbc.message.client.PrepareExecutePacket"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>index</title>
<style type="text/css">
table {
    width: 800px;
    border-collapse: collapse;
}
 
td {
    text-align: center;
    border-bottom: #c0c0c0 1px solid;
}
 
tbody tr:hover {
    background-color: silver;
}
 
.w1 {
    width: 10%;
}
 
.w2 {
    width: 20%;
}
 
.w3 {
    width: 30%;
}
 
.w5 {
    width: 40%;
    text-align: left;
}
 
tr {
    height: 35px;
}
</style>
<script src="./js/write.js" charset="UTF-8"></script>
</head>
<body>
    <h1>index</h1>
    <%
    BoardDAO dao = new BoardDAO();
    List<Map<String, Object>> list = dao.boardList();
    %>
    <!-- 자바 코드를 여러줄 쓸때는  < % % >
    자바의 값 하나를 출력할 때는 < % = % > -->
 
    <table>
        <thead>
            <tr>
                <th>번호</th>
                <th>제목</th>
                <th>글쓴이</th>
                <th>날짜</th>
                <th>조회</th>
            </tr>
        </thead>
 
        <tbody>
            <%
            //sevlet 서블릿 : 자바코드 속에 html이 있어요.
            //jsp java server page : html코드 속에 java가 있어요
 
            for (Map<String, Object> map : list) {//포문이니까 텍스트로 다 바꿀때까지 반복
            %>
            <tr>
                <td class="w1"><%=map.get("board_no")%></td>
                <td class="w5"><a href="./detail.jsp?no=<%=map.get("board_no")%>"> 
<%=map.get("board_title")%></a></td>
                <td class="w2"><%=map.get("board_write")%></td>
                <td class="w3"><%=map.get("board_date")%></td>
                <td class="w1"><%=map.get("board_count")%></td>
 
            </tr>
            <%
            }
            %>
        </tbody>
    </table>
 
    <button onclick="write1()">글쓰기</button>
    <script type="text/javascript">
        function write1() {
            if (confirm("정말 글쓰기를 실행하실겁니까?")) {
                location.href = "./write.jsp";
            } else {
                alert("휴, 다행입니다. 원복합니다.");
            }
        }
    </script>
 
 
    연습
    <a href="./test">여기</a>를 눌러주세요.
    <br>연습
    <a href="./main.jsp">main</a>를 눌러주세요.
 
 
</body>
</html>
cs

'2023.11.21-2024.05.31' 카테고리의 다른 글

240102 HTML detail.jsp  (1) 2024.01.03
240102 HTML delete.jsp  (1) 2024.01.03
240103 JAVA IO(OutputStream,InputStream)  (1) 2024.01.03
240103 JAVA Stack  (0) 2024.01.03
240103 JAVA Inner  (0) 2024.01.03