【问题标题】:Binding model to view with Spring Web Flow绑定模型以使用 Spring Web Flow 查看
【发布时间】:2016-01-23 07:20:47
【问题描述】:

我在将模型绑定到表单视图时遇到了问题,我遇到了错误

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>

【问题讨论】:

    标签: java spring spring-mvc thymeleaf spring-webflow


    【解决方案1】:

    错误消息告诉您 Location 或 Place 为空。

    如果我不得不猜测你可能没有初始化模型放置在你的流 xml 之前进入视图状态 mapView

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

    虽然您可能希望使用工厂方法来初始化 Place(因此您也可以在 1 次调用中初始化 Location)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      相关资源
      最近更新 更多