타임리프 문법으로 경로 수정하는데 적용이 안되는것 같습니다
353
작성한 질문수 2
상품목록-타임리프 강의에서
<tr th:each="item : ${items}">
<td><a href="item.html" th:href="@{/basic/items/{itemId} (itemId=${item.id})}" th:text="${item.id}">회원id</a></td>
<td><a href="item.html" th:href="@{|/basic/items/${item.id}|}" th:text="${item.itemName}">상품명</a></td>
<td th:text="${item.price}">10000</td>
<td th:text="${item.quantity}">10</td>
</tr>
이코드를 따라쳤는데도 안되서 강의 자료에있는걸 복사 붙여넣기했는데도
경로가 수정이 안됩니다.. 왜그럴까요 ??ㅠㅜ
답변 1
0
안녕하세요. 김태환님, 공식 서포터즈 OMG입니다.
강의 코드를 사용하여도 동일한 문제면, 해당 부분이 아닌 관련된 다른 부분에서 문제로 보이네요
<a href="item.html" th:href="@{/basic/items/{itemId} (itemId=${item.id})}"
<a href="item.html" th:href="@{|/basic/items/${item.id}|}"
처리하는 컨트롤러 코드를 확인해주세요.
해결이 안될 경우 댓글남겨주세요
감사합니다.
0
안녕하세요. 저도 같은 문제를 겪고 있는데요! 해결방안을 알고 싶습니다.
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<link th:href="@{/css/bootstrap.min.css}"
href="../css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container" style="max-width: 600px">
<div class="py-5 text-center">
<h2>상품 목록</h2>
</div>
<div class="row">
<div class="col">
<button class="btn btn-primary float-end"
onclick="location.href='addForm.html'"
th:onclick="|location.href='@{/basic/items/add}'|"
type="button">상품 등록
</button>
</div>
</div>
<hr class="my-4">
<div>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>상품명</th>
<th>가격</th>
<th>수량</th>
</tr>
</thead>
<tbody>
<tr th:each="item:${items}">
<td><a href="item.html" th:href="@{/basic/items/{itemId}(itemId=${item.id})}" th:text="${item.id}">회원id</a></td>
<td><a href="item.html" th:href="@{|/basic/items/${item.id}|}" th:text="${item.itemName}">상품명</a></td>
<td th:text="${item.price}">10000</td>
<td th:text="${item.quantity}">23</td>
</tr>
</tbody>
</table>
</div>
</div> <!-- /container -->
</body>
</html>
mvc 패턴 - 적용 강의에서 회원가입할 때 redirect가 아닌 forward인 이유가 궁금합니다.
0
31
1
servlet과 container에 대한 질문입니다
0
54
1
api를 어느 컨트롤러에 작성해야하는지는 어떤 기준으로 해야하나요?
0
86
1
jsp 의존성 수정 요청
0
128
2
요즘 웹 서버가 주로 사용되는 이유는 SPA 구조 때문일까요 ?
0
161
1
save() 메서드 문의
0
78
1
절대 경로로 templates/basic 하위 파일 열면 css 적용 안되는 현상
0
114
1
request-body-json
0
97
2
MVC 패턴의 적용 단위
0
103
1
RequestMapping을 이용한 핸들러, 어댑터
0
124
2
save 후 결과화면
0
101
2
jsp를 이용한 view
0
102
1
application.properties에 debug 추가해도 결과가 똑같습니다.
0
195
1
수업 코드 제공 관련 문의
0
107
2
RequestMappingHandlerAdapter의 Controller 호출 과정
0
109
3
파일 오픈 시
0
76
1
스프링 배치 관련
0
81
1
@RequestParam의 defaultValue가 blank 값도 처리하는 지 여부
0
115
1
postman으로 /request-body-json-v1 호출시 500 error
0
109
1
프론트엔드와 백엔드의 mvc, rest api에 대한 질문
0
90
1
모델의 역할과 계층 분리에 대한 이해 차이 + 추가질문
0
119
1
console log 출력 관련 질문입니다.
0
80
1
애플리케이션이 실행 되지 않습니다 ㅠㅠㅠ
0
149
1
html 변경하는 부분 적용 문제
0
109
1





