简体   繁体   中英

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

<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

<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.

If I had to guess you probably did not initialize the model Place inside your flow xml before entering the view-state mapView

<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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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