티스토리 뷰

728x90

기존에 사용하던 방식은 다음과 같았다.

아무런 문제가 생기지 않아 그냥 한번 잘 만들어두고 잘 복사해서 쓰고 있었는데 

이번에 Bootstrap의 modal을 이용하면서 아래와 같은 형태로 사용하면서 에러가 발생했다.

th:onclick="|retrievePackageData('${orderItem.trackingNumber}');|"

 

에러의 내용은 다음과 같다.

Caused by: org.attoparser.ParseException: 
Only variable expressions returning numbers or booleans are allowed 
in this context, any other datatypes are not trusted in the context 
of this expression, including Strings or any other object that 
could be rendered as a text literal. A typical case is HTML 
attributes for event handlers (e.g. "onload"), in which textual 
data from variables should better be output to "data-*" 
attributes and then read from the event handler.

 

찾아보니 타임리프 문법상의 업데이트로 인한 변경이었고 

아래와 같이 사용하여 문제가 해결되었다.

 

th:onclick="retrievePackageData([[${orderItem.trackingNumber}]])"

 

에러의 내용으로는 data-XXX=""식으로 데이터를 바인딩해서 사용하라고 하니 좀 더 알아보아야 할 것.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함