Java 为什么webflow不更新我的模型对象?
我正在使用SpringWebflow2设置一个应用程序,我遇到了一个问题。该应用程序在一个页面上接受预订,然后在另一个页面上允许付款。预订模型对象运行良好;我可以填写表单,提交表单,然后在下面的确认屏幕上显示完全填充的对象。但是,当我对paymentInformation模型对象执行相同的操作时,在处理表单时,表单的任何内容都不会绑定到模型对象中 这是我的流定义。在尝试解决此问题时,我将支付流移动到了子流中Java 为什么webflow不更新我的模型对象?,java,spring-webflow,spring-webflow-2,Java,Spring Webflow,Spring Webflow 2,我正在使用SpringWebflow2设置一个应用程序,我遇到了一个问题。该应用程序在一个页面上接受预订,然后在另一个页面上允许付款。预订模型对象运行良好;我可以填写表单,提交表单,然后在下面的确认屏幕上显示完全填充的对象。但是,当我对paymentInformation模型对象执行相同的操作时,在处理表单时,表单的任何内容都不会绑定到模型对象中 这是我的流定义。在尝试解决此问题时,我将支付流移动到了子流中 <?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<flow
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/webflow"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="paymentInfo" class="com.myapp.payments.domain.PaymentInfo" />
<input name="reservation" />
<decision-state id="paymentDecision">
<if test="reservationServiceImpl.needsPayment(reservation)"
then="enterPayment"
else="resolvePayment" />
</decision-state>
<view-state id="enterPayment" view="enterPayment" model="paymentInfo">
<on-render>
<evaluate expression="reservationMultiAction.preparePayment" />
<set name="viewScope.stepNumber" value="3" />
</on-render>
<transition on="back" to="editReservation" />
<transition on="submitPayment" to="resolvePayment" />
</view-state>
<action-state id="resolvePayment">
<evaluate expression="reservationMultiAction.submitPayment" />
<transition on="success" to="receipt" />
<transition on="failure" to="payment" />
</action-state>
<end-state id="editReservation" />
<end-state id="receipt" />
</flow>
调用preparePayment在flowScope中填充bean,然后在enterPayment页面上正确填充表单。但是当我调试submitPayment操作方法时,paymentInfo bean只有preparePayment的结果,而提交表单中没有任何结果
因为我相信有人会问,下面是enterPayment页面的开始表单标签:
<form:form modelAttribute="paymentInfo" method="post">
如果未包含完整的html代码,则很难识别错误。乍一看,它可能是表单标记中缺少的操作属性
<form:form action="${flowExecutionUrl}" modelAttribute="paymentInfo" method="post">
<input type="submit" id="_eventId" value="submitPayment" />
</form:form>
它没有错过动作,因为它是自动发回到流中的,但是你让我看到了正确的位置。我们使用不使用提交输入类型的自定义按钮,我将其与流程中其他不提交表单的按钮混合在一起。我让按钮只是链接到下一个视图状态,而不是提交表单,这就是为什么它移动到了正确的位置,但行为错误。解决这样一个恼人的问题很容易。