如何使用 Spring weblow 提交表单

How to submit form using Spring weblow

下面是我在 jsp 和流程 xml 中的代码片段,在尝试提交表单时我的页面正在刷新,但请求没有发送到服务器。请协助。

Jsp

<form action="${flowExecutionUrl}" modelAttribute="employeeDto" method="post">
<div class="formButton">
    <input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}" /> 
    <input  name="_eventId_nextBtn" type="submit" value="submit">
</div>
</form>


Flow xml

<flow xmlns="http://www.springframework.org/schema/webflow"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd">

<var name="employeeDto" class="com.school.transferobjects.EmployeeDto"/>
<view-state id="employeeView" model="employeeDto" view="employee">
    <transition on="nextBtn" to="createEmployee" />
</view-state>

    <action-state id="createEmployee">
        <evaluate   
        expression="employeeHelper.saveEmployee(flowRequestContext,employeeDto)"
         result="flowScope.res"/>

        <transition on="${flowScope.res.success=='success'}" to="student.do"/> 
    </action-state>

</flow>

我认为 eventId 未被识别,因此当您通过单击按钮提交时没有找到 eventId,导致流程执行被刷新。 确保包含表单标签:

    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    <form:form modelAttribute="yourModel" method="post">
    ...
    </form:form>