如何在Spring Web流程中将业务服务返回的值存储在变量中?

时间:2016-04-09 09:30:40

标签: spring jsp spring-mvc spring-webflow spring-webflow-2

情况:我正在开发一个spring mvc网络流程应用,因为我有两个表customercustomerAdress以及两个相应的模型:customerModelcustomerAdressModel,现在跟随我的flow.xml:

   <var name="customer" class="com.model.Customer"/>
   <var name="customerAdress" class="com.model.CustomerAdress"/>
   <var name="id">

   <view-state id="customer" view="customerView.jsp" model="customer">

    <transition on="next" to="customerAdress"/>
    </view-state>

    <view-state id="customerAdress" view="customerAdressView.jsp" model="customerAdress">

    <transition on="next" to="insertCustomer"/>
    </view-state>

   <action-state id="insertCustomer">
    <evaluate expression="Buisness.insertCustomer(customer)"/>
    <evaluate expression="Buisness.fetchCustomerId(customer)" result="id"/>
    <evaluate expression="Buisness.insertCustomerAdress(id,cutomerAdress)"/>
    </action-state> 

现在insertCustomer插入客户,fetchCustomerId提取客户ID,insertCusotomerAdressid

插入客户地址

问题:我的问题是此代码无效,具体insertCustomerAdress无法正常工作,我认为我在判断id或分配商务服务的价值方面犯了一些错误到id,有人可以告诉我正确的语法吗?

1 个答案:

答案 0 :(得分:0)

默认情况下,操作状态仅执行第一个操作。要执行一系列操作,请使用Named actions

<action-state id="insertCustomer">
    <evaluate expression="Buisness.insertCustomer(customer)">
        <attribute name="name" value="insertCustomer" />
    </evaluate>
    <evaluate expression="Buisness.fetchCustomerId(customer)" result="id">
        <attribute name="name" value="fetchCustomerId" />
    </evaluate>
    <evaluate expression="Buisness.insertCustomerAdress(id,cutomerAdress)">
        <attribute name="name" value="insertCustomerAdress" />
    </evaluate>
    <transition on="insertCustomerAdress.success" to="[state id to transit]" />
</action-state>