inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화

조회용 샘플 데이터 입력

모든 주문리스트 조회하는 타임리프 올려봅니다.

해결된 질문

582

twosom

작성한 질문수 69

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시간넘게걸렸네요 .. ㅠㅠㅠㅠㅠㅠ

JPA java spring-boot spring

답변 1

2

김영한

if0rever님

좋은 내용 공유해주셔서 감사합니다.

강의 관련 외 질문입니다.

0

64

2

SpringBoot4 + Hibernate7 모듈 등록 방법 공유

0

85

1

BeanCreationException

0

86

3

Update 후 UpdateMemberResponse 매핑할 때

0

46

1

트랜잭션을 사용 안 할 때 커넥션은 언제 가져오나요?

0

96

2

페이징 + 검색조건 관련해서 질문드립니다.

0

70

1

Query Dsl Q파일 질문입니다.

0

81

1

루트 쿼리라는것은

0

58

1

메서드를 분리하는 기준

0

61

1

findAllWithMemberDelivery 메서드 질문드립니다.

0

108

3

연관관계 매핑을 안 쓸 경우, 사용해야 하는 전략

0

83

2

fetch join과 영속화와 OSIV의 관계

0

83

2

Distinct 사용 전 결과에 대한 의문

0

112

2

레포지토리 계층에서의 트랜잭션에 대한 의문

0

55

1

영속성 컨텍스트 생명주기의 신기한 부분이 있습니다.

0

77

2

dto 필드 속 엔티티 여부

0

58

1

뷰템플릿 사용 시

0

76

2

Result 클래스 관련 질문

0

56

1

@PostConstruct 프록시 관련 질문드립니다

0

85

1

DTO 대신 Form 사용은 안되나요?

0

133

1

OSIV ON 상태일 때

0

94

1

fetch join VS fetch join 페이징 궁금증

0

179

2

양방향 연관관계 알아보는 법?

0

104

1

16강 17강 간단 정리 이게 맞을까요 ?

0

163

2