[thymleaf] 타임리프 키값이 없을때 #maps.containsKey()

728x90
반응형
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/quality/qualityInspectionRequestList.html]")] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method getInspection_request_approval() cannot be found on type java.util.HashMap

오류원인

값이 null일때 컬럼 자체를 안가져오는 것

 

해결

이럴때 쓰는 타임리프 함수

#maps.containsKey()

해당 키 값이 있는지 확인해준다.

 

 

th:text="${#maps.containsKey(l, 'inspection_request_approval') ? l.inspection_request_approval: '' }"
 

 

728x90
반응형