[英]Binding model to view with Spring Web Flow
我在綁定模型到表單視圖時出現問題,即時通訊出現錯誤
Property or field 'city' cannot be found on null
我正在嘗試將String place.location.city
綁定到我的視圖
<form role="form" th:action="${flowExecutionUrl}" th:object="${place}" method="post">
<input class="form-control" th:field="*{location.city}"/>
<!-- ... -->
</form>
這是我收到錯誤的子流的xml
<view-state id="mapView" view="/places/add/location" model="place">
<transition on="locationSelected" to="locationReady"/>
</view-state>
<end-state id="locationReady">
</end-state>
錯誤消息告訴您Location或Place為空。
如果我不得不猜測您可能未在進入視圖狀態mapView 之前將模型Place放入流程xml中
<set name="flowScope.place" value ="new your.class.path.model.Place()"/>
雖然您可能想使用Factory方法來初始化Place(因此您也可以在1次調用中初始化Location)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.