简体   繁体   English

绑定模型以使用Spring Web Flow查看

[英]Binding model to view with Spring Web Flow

i've trobule with binding model to form view, im getting error 我在绑定模型到表单视图时出现问题,即时通讯出现错误

Property or field 'city' cannot be found on null

I'm trying to bind String place.location.city to my view 我正在尝试将String place.location.city绑定到我的视图

<form role="form" th:action="${flowExecutionUrl}" th:object="${place}" method="post">
 <input class="form-control" th:field="*{location.city}"/>
<!-- ... -->
</form>

This is my xml of subflow where i'm getting error 这是我收到错误的子流的xml

<view-state id="mapView" view="/places/add/location" model="place">
    <transition on="locationSelected" to="locationReady"/>
</view-state>

<end-state id="locationReady">
</end-state>

Error msg is telling you that either Location or Place is null. 错误消息告诉您Location或Place为空。

If I had to guess you probably did not initialize the model Place inside your flow xml before entering the view-state mapView 如果我不得不猜测您可能未进入视图状态mapView 之前将模型Place放入流程xml中

<set name="flowScope.place" value ="new your.class.path.model.Place()"/>

Though you will probably want to use a Factory Method to init Place (so you can also init Location in 1 call) 虽然您可能想使用Factory方法来初始化Place(因此您也可以在1次调用中初始化Location)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM