<th:block th:each="item : ${mclist}" >
<option th:if="${item.id}" th:value="${item.id}" th:text="${item}"></option>
<option th:if="${item.id == null}" th:value="${item}" th:text="${item}"></option>
</th:block>
Объектом 'item' может быть любая сущность. Поэтому он может содержать или не содержать поле 'id'. Код, представленный здесь, выдает следующую ошибку, когда объект не содержит поле 'id'.
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'id' cannot be found on object of type 'java.lang.String' - maybe not public or not valid?
Возможно ли проверить наличие поля id в объекте 'item' перед извлечением его значения?