我正在使用Spring Web Flow 2,并且遇到一个基本问题,无法正确过渡。我已经在Internet上进行了很多搜索,但是未能找到关于如何从视图侧触发转换的深入说明。我有两种状态:enterBookingDetails和reviewBooking。 EnterBookingDetails工作正常-页面正在加载,并且在提交事件时,会加载reviewBooking。我的问题是,我无法实现从reviewBooking到工作的任何过渡。这是我所拥有的:
booking-flow.xml:
<var name="bookingForm" class="com.mypackage.CarBookingForm"/>
<view-state id="enterBookingDetails" model="bookingForm">
<transition on="submit" to="reviewBooking" />
</view-state>
<view-state id="reviewBooking" model="bookingForm">
<transition on="confirm" to="bookingConfirmed" />
<transition on="revise" to="enterBookingDetails" />
<transition on="cancel" to="bookingCancelled" />
</view-state>
<end-state id="bookingConfirmed" />
<end-state id="bookingCancelled" />
enterBookingDetails.jsp(节选):
<form:form modelAttribute="bookingForm">
Pickup: <form:input path="pickUpLocation"/><br />
Dropoff: <form:input path="dropOffLocation"/><br />
<input type="submit" name="_eventId_submit" value="Confirm"/>
<input type="submit" name="_eventId_other" value="Other"/>
</form:form>
reviewBooking.jsp(节选):
Pickup Loc: ${bookingForm.pickUpLocation}<br />
Dropoff Loc: ${bookingForm.dropOffLocation}<br />
<form>
<input type="submit" name="_eventId_confirm" value="Confirm" />
<input type="submit" name="_eventId_revise" value="Revise" />
<button type="submit" name="_eventId_cancel">Cancel</button>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}" />
</form>
当单击“ reviewBooking”上的任何按钮时,用户将被带回到“ enterBookingDetails”,并且不填充任何表单数据。在此先感谢您的帮助。
最佳答案
好,我知道了问题所在。实际上,所有过渡都在触发。问题在于,这两个有问题的过渡都进入了结束状态,而我没有意识到,默认情况下,这些过渡会结束流程,然后重定向回第一页。