해결된 질문
작성
·
556
17
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/header :: header"></head>
<body>
<div class="container">
<div th:replace="fragments/bodyHeader :: bodyHeader"></div>
<div>
<div>
<form th:object="${orderSearch}" class="form-inline">
<div class="form-group mb-2">
<input type="text" th:field="*{memberName}" class="form- control" placeholder="회원명"/>
</div>
<div class="form-group mx-sm-1 mb-2">
<select th:field="*{orderStatus}" class="form-control">
<option value="">주문상태</option>
<option th:each="status : ${T(jpabook.jpashop.domain.OrderStatus).values()}"
th:value="${status}"
th:text="${status}">option
</option>
</select>
</div>
<button type="submit" class="btn btn-primary mb-2">검색</button>
</form>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>#</th> <th>회원명</th> <th>대표상품 이름</th> <th>대표상품 주문가격</th> <th>대표상품 주문수량</th> <th>상태</th> <th>일시</th>
<th></th>
</tr>
</thead>
<tbody>
<span th:each="item : ${orders}">
<tr th:each="orderItem : ${item.orderItems}">
<td th:text="${orderItem.item.id}"></td>
<td th:text="${item.member.name}"></td>
<td th:text="${orderItem.item.name}"></td>
<td th:text="${orderItem.orderPrice}"></td>
<td th:text="${orderItem.count}"></td>
<td th:text="${item.status}"></td>
<td th:text="${item.orderDate}"></td>
<td>
<a th:if="${item.status.name() == 'ORDER'}" href="#"
th:href="'javascript:cancel('+${orderItem.order.id}+')'"
class="btn btn-danger">CANCEL</a>
</td>
</tr>
</span>
</tbody>
</table>
</div>
<div th:replace="fragments/footer :: footer"></div>
</div> <!-- /container -->
</body>
<script>
function cancel(id) {
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "/orders/" + id + "/cancel");
document.body.appendChild(form);
form.submit();
}
</script>
</html>
구글 뒤져가면서 왜 이중 each를 쓰는데 인텔리제이가 빨간줄 긋지...싶었는데
tr을 두번으로 each하면 안되나봅니다. ㅠㅠ
바깥의 each를 span태그로 바꿔주니까 잘되는거같네요!
혹시나 막히시는 분들은 참고하셔요!
이거 만드는데 1시간넘게걸렸네요 .. ㅠㅠㅠㅠㅠㅠ