2017-02-21 66 views
0

我有一個包含一個Address對象像這樣的個人目標結合的複合模式:如何使用Spring Web Flow的

class Person { 
    private int age; 
    private Address address; 

public int getAge() { 
    return age; 
} 

public void setAge(int age) { 
    this.age = age; 
} 

public Address getAddress() { 
    return address; 
} 

public void setAddress(Address address) { 
    this.address= address; 
} 
} 

和A類地址:

class Address{ 

    private String streetAddress; 
    private String city; 

public String getCity() { 
    return city; 
} 

public void setCity(String city) { 
    this.city = city; 
} 

public String getStreetAddress() { 
    return state; 
} 

public void setStreetAddress(String streetAddress) { 
    this.state = state; 
} 
} 

在我的Spring Web Flow的,我有:

<var name="person" class="Person"/> 
<var name="address" class="Address"/> 

    <view-state id="view1" view="qualificationView" model="person"> 

    <transition on="submitApplication" to="view2"/> 
</view-state> 

我的HTML有屬性:

age 
streetAddress 
city 

在表單提交上,我看到「age」屬性正確綁定,但Address類中的屬性未被設置。

如何讓它設置所有的字段?

回答

1
<form:input type="text" path="address.streetAddress"/> 

而且您不需要定義<var name="address".../>。我想你必須在Personnew Address()之間明確初始化address

+0

This Works,thank you so so much! – Prasanna