28. 물품 목록
-물품 목록
*select_item get 생성(SellerController.java)
... ...
// 127.0.0.1:8080/ROOT/seller/select_item
@GetMapping(value = "/select_item") // 물품목록
public String selectItemGet(Model model) {
List<Item> list = iRepository.findAllByOrderByNoAsc();
model.addAttribute("list", list);
return "select_item";
}
... ...
*목록 페이지 구성(select_item.jsp)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>select_item.jsp</title>
</head>
<body>
<a th:href="@{/seller/insert_item}">물품등록</a>
<hr />
<table border="1">
<tr>
<th>번호</th>
<th>물품코드</th>
<th>물품명</th>
<th>물품내용</th>
<th>가격</th>
<th>수량</th>
<th>등록일자</th>
<th>이미지 등록</th>
</tr>
<tr th:each="itm, idx : ${list}">
<td th:text="${idx.count}"></td>
<td th:text="${itm.no}"></td>
<td th:text="${itm.name}"></td>
<td th:text="${itm.content}"></td>
<td th:text="${itm.price}"></td>
<td th:text="${itm.quantity}"></td>
<td th:text="${itm.regdate}"></td>
<td> <a th:href="@{/seller/insert_item_image(no=${itm.no})}">이미지 등록</a></td>
</tr>
</table>
</body>
</html>
*목록 확인
-필요없는 내용 빼기(content 빼기)
*entity 생성(ItemProjection.java)
*표시할 get 변수만 입력한다.
package com.example.entity;
import java.util.Date;
public interface ItemProjection {
// 참고 : Item.java엔티티를 참고함
// 필요한 get 변수만 설정
Long getNo();
String getName();
Long getPrice();
Long getQuantity();
Date getRegdate();
}
*저장소 조건 추가(ItemRepository.java)
... ...
List<ItemProjection> findAllByOrderByNoAsc();
*select_item수정(SellerController.java)
... ...
List<ItemProjection> list = iRepository.findAllByOrderByNoAsc();
... ...
*jsp 수정
*content 제거
... ...
<table border="1">
<tr>
<th>번호</th>
<th>물품코드</th>
<th>물품명</th>
<th>가격</th>
<th>수량</th>
<th>등록일자</th>
<th>이미지 등록</th>
</tr>
<tr th:each="itm, idx : ${list}">
<td th:text="${idx.count}"></td>
<td th:text="${itm.no}"></td>
<td th:text="${itm.name}"></td>
<td th:text="${itm.price}"></td>
<td th:text="${itm.quantity}"></td>
<td th:text="${itm.regdate}"></td>
<td> <a th:href="@{/seller/insert_item_image(no=${itm.no})}">이미지 등록</a></td>
</tr>
</table>
... ...
*화면 확인
'Spring' 카테고리의 다른 글
Spring 일지 #30 (20210914) 화면 구현(이미지 등록) (0) | 2021.09.27 |
---|---|
Spring 일지 #29 (20210914) 화면 구현(이미지 entity, 저장소 등록) (0) | 2021.09.27 |
Spring 일지 #27 (20210914) 화면 구현(물품 등록) (0) | 2021.09.27 |
Spring 일지 #26 (20210914) 화면 구현(물품 entity, 저장소 등록) (0) | 2021.09.27 |
Spring 일지 #25 (20210914) 화면 구현(주소 삭제, 수정) (0) | 2021.09.24 |