SpringBoot 게시판 만들기

스프링부트(SpringBoot) 게시판 만들기6 - 게시글 목록(list) + jstl 태그 사용

abfc 2017. 8. 20.
반응형

게시글 목록(list) + jstl 태그 사용






1.  jstl 태그 사용을 위해 pom.xml에 jstl 라이브러리 추가

1
2
3
4
5
6
<!-- JSTL -->
        <dependency>
               <groupId>jstl</groupId>
               <artifactId>jstl</artifactId>
               <version>1.2</version>
          </dependency>
cs





2. list.jsp에 태그 추가


1
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
cs






3. list.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
<%@ 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 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>List</title>
</head>
<body>
 
<h2> 게시글 목록 </h2>
 
<button class="btn btn-primary" onclick="location.href='/insert'">글쓰기</button>
 
<div class="container">
    <table class="table table-hover">
        <tr>
            <th>No</th>
            <th>Subject</th>
            <th>Writer</th>
            <th>Date</th>
        </tr>
          <c:forEach var="l" items="${list}">
              <tr>
                  <td>${l.bno}</td>
                  <td>${l.subject}</td>
                  <td>${l.writer}</td>
                  <td>${l.reg_date}</td>
              </tr>
          </c:forEach>
          
    </table>
</div>
 
 
<%@ include file="bootstrap.jsp" %>
</body>
</html>
cs





4. 프로젝트 재 실행후 확인 http://localhost:8080/list






게시글 목록 끝


반응형

댓글

💲 추천 글