[Thymeleaf Error] : EL1007E: Property or field 'id' cannot be found on null

μ†‘μ±„μ˜Β·2023λ…„ 8μ›” 6일
0

EL1007E: Property or field 'id' cannot be found on null

πŸ“μ—λŸ¬λ¬Έκ΅¬

Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "product.id" (template: "admin/admin_product" - line 66, col 88)

πŸ“ν•΄κ²°

<a href="javascript:void(0);" onclick="return confirm('μ •λ§λ‘œ μ‚­μ œν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?');" 
th:href="@{|/ad/product/delete/${product?.id}|}">
<button type="button" class="date_btn" style="color: black;">μ‚­μ œ</button>
</a>

"{product.id}"λ₯Ό "{product?.id}"둜 μˆ˜μ •ν•˜κ³  ν•΄κ²°ν–ˆλ‹€.

?은 null이 λ°œμƒν•  수 μžˆλŠ” ν”„λ‘œνΌν‹°μ— λ„£λŠ”λ‹€.

μ—¬κΈ°μ„œ ?λŠ” ifλ₯Ό μ˜λ―Έν•œλ‹€.

0개의 λŒ“κΈ€