wenn ${object}
ist null, dann seine Einzelteile besucht von *{item}
verursachen würde zu finden:thymeleaf oder der Bereich kann nicht auf null
org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'item' cannot be found on null
So wie diese zu lösen und ich möchte blieb die div Struktur haben, wie in Im folgenden Beispiel, wenn currentUser
null ist, div
enthält Stadt und Name bleibt.
<div class="form" th:object="${currentUser}">
<div class="form-group form-group-sm">
<label>city:</label>
<span id="details_city" th:text="*{address == null ? '' : address.city}">Hongkong</span>
</div>
<div class="form-group form-group-sm">
<label>name:</label>
<span id="details_username" th:text="*{name}">Jane</span>
</div>
</div>
Ich wäre wieder da, wenn ich deine Idee versuche. :) – Tiina