Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "{id}"

myeonji·2022년 1월 29일
1

Error

목록 보기
4/8

Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: "{id}"

<form th:action="@{/user/{id}/checkout/cancel/{orderItemId}(id=${user.id}, orderItemId=${orderItem.id})}" th:method="POST">
                            <input id="id" name="id" type="hidden" />
                            <input id="orderItemId" name="orderItemId" type="hidden" />
                            <td class="btn btn-outline-dark"><button type="submit">주문취소</button></td>
                        </form>

id와 orderItemId에 정수값이 넘어가지 않고 문자열이 넘어간다는 뜻인 것 같다.

<form th:action="@{/user/{id}/checkout/cancel/{orderItemId}(id=${user.id}, orderItemId=${orderItem.id})}" th:method="POST">
                            <input id="id" name="id" type="number" />
                            <input id="orderItemId" name="orderItemId" type="number" />
                            <td class="btn btn-outline-dark"><button type="submit">주문취소</button></td>
                        </form>

type="number"로 바꾸니까 정수값으로 잘 넘어간다!!

짜잔!!! ㅇㅑ호!!!!

-> 수정 : 쇼핑몰 프로젝트 주문 취소 기능을 구현할 때 공부한 부분인데, input 태그는 없어야 한다. 입력 받는 것이 아닌 데이터를 그냥 넘겨주는 것이기 때문이다.

0개의 댓글