如何使用Spring webflow提交表单

时间:2015-03-22 07:28:28

标签: spring forms spring-webflow

以下是jsp&的代码片段。 flow 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>

1 个答案:

答案 0 :(得分:0)

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

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