> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/jpa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/jpa/7./undefined-4.md).

# 상품 목록

구현할 내용

1. 컨트롤러 : ItemController 클래스\
   @GetMapping("/items")

```java
@GetMapping("/items")
public String list(Model model){
  List<Item> items = itemService.findItems();
  model.addAttribute("items",items);
  return "items/itemList";
}
```

&#x20; 2\. 타임리프 템플릿 : itemList.html\
회원 목록 조회와 동일하다.

```markup
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/header :: header" />
<body>
<div class="container">
  <div th:replace="fragments/bodyHeader :: bodyHeader"/>
  <div>
    <table class="table table-striped">
      <thead> <tr>
        <th>#</th> <th>상품명</th> <th>가격</th> <th>재고수량</th> <th></th>
      </tr>
      </thead>
      <tbody>
      <tr th:each="item : ${items}">
        <td th:text="${item.id}"></td>
        <td th:text="${item.name}"></td>
        <td th:text="${item.price}"></td>
        <td th:text="${item.stockQuantity}"></td>
        <td>
          <a href="#" th:href="@{/items/{id}/edit (id=${item.id})}" class="btn btn-primary" role="button">수정</a>
        </td> </tr>
      </tbody>
    </table>
  </div>
  <div th:replace="fragments/footer :: footer"/>
</div> <!-- /container -->
</body>
</html>
```

![상품들이 추가된 상품 목록 조회 화면](https://1491120136-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MeIsSQVBsQu8Hb7mOOk%2F-MeQ2P-IHtkDR__EYbPe%2F-MeQ2S1Fl_7b_c0hCuVH%2FScreen%20Shot%202021-07-12%20at%2011.07.09%20PM.png?alt=media\&token=cc50ca16-cdb0-4f6d-a0ac-08f54ee6ebc6)
