如何在Spring WebFlow2中将新模型传递给视图状态

时间:2012-09-11 15:33:44

标签: java spring spring-mvc spring-webflow

如何在Spring WebFlow2中将新模型传递给视图状态。我有一个输入屏幕,我的用户输入一些数据,然后它返回服务器进行处理。如果数据没问题,那么我必须设置一个Ticket Model并将其传递给下一个要显示的视图状态。

我无法获得下一个视图状态来显示故障单中的数据。有人可以帮帮我。

我的流程:

<view-state id="MemberInquiry" view="question.jsp" model="memberrequest" >
        <transition on="submit" to="endState">
            <evaluate expression="flowActions.addInquiry(memberrequest)" result="flowScope.ticket"/>
        </transition>

        <transition on="cancel" to="endState" bind="false"/>
    </view-state>

    <view-state id="endState" view="thanks.jsp" >

    </view-state>

以下是控制器中的代码:

public Ticket addInquiry(MemberRequest memberrequest) {

        LOGGER.debug("[" + memberrequest.toString() + "]");

        // Setting data over to RT

        String Ticket = memberInquiryService.sentWebRequest(memberrequest);

        /*
         * Setting out the ticket number to be displayed to user
         */

        Map<String, Object> model = new HashMap<String, Object>();
        Ticket t = new Ticket();
        t.setTicketDetails(Ticket);

        LOGGER.debug("[" + t.toString() + "]");

        return t;
    }

以下是感谢页面中的代码:

<p>
    Thanks for submitting.  We will get back to you as soon as possible.
    <p>
    <c:out value="${ticket.TicketDetails}" />
    <br>
    </div>

1 个答案:

答案 0 :(得分:2)

尝试动作状态:

<transition on="submit" to="addInquiry" />

<action-state id="addInquiry">
    <evaluate expression="flowActions.addInquiry(memberrequest)" result="flowScope.ticket"/>
    <transition to="endState" />
</action-state>