我有Spring 3应用程序,将Tiles2作为视图解析器。每当我点击"提交"按钮下一个jsp页面应该显示但是它保持在同一页面上。
我在/ WEB-INF / flow目录中有一个文件WebFlow.xml文件,而JSP也在同一个文件夹中。
我的配置如下: -servlet.xml后缀
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:flow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="com.controller.*"/>
<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.tiles2.TilesViewResolver"/>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<flow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>
<flow:flow-registry id="flowRegistry">
<flow:flow-location path="/WEB-INF/flow/WebFlow.xml" id="flow"/>
</flow:flow-registry>
<bean id="flowHandlerMapping" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry"/>
</bean>
<bean id="flowHandlerAdapter" class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor"/>
</bean>
</beans>
WebFlow.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.0.xsd">
<var name="studentRegForm" class="com.formbean.flows.StudRegForm"/>
<view-state id="login" view="login">
<transition on="studentReg" to="studentReg"/>
</view-state>
<view-state id="studentReg" view="studentReg" model="studentRegForm">
<transition on="submitStudInfo" to="studConfirmPage"/>
</view-state>
<view-state id="studConfirmPage">
<transition on="submit" to="showStoredPage"/>
<transition on="Cancel" to="studentReg"/>
</view-state>
<end-state id="showStoredPage"/>
</flow>
的login.jsp
<sf:form id="loginFrm" modelAttribute="loginForm" method="GET" action="${flowExecutionUrl}">
<input type="text" name="_flowExecutionKey" value="${flowExecutionKey}"/>
<input type="submit" value="Student Registration" name="_eventId_studentReg"/>
</sf:form>
StudentReg.jsp
<sf:form id="studRegFrm" modelAttribute="studentRegForm" method="GET" action="${flowExecutionUrl}">
<input type="text" name="_flowExecutionKey" value="${flowExecutionKey}"/>
<table>
<tr>
<td><sf:label path="name">Please Enter Name:</sf:label></td>
<td><sf:input path="name"/></td>
</tr>
<tr>
<td><sf:label path="address">Please Enter Address:</sf:label></td>
<td><sf:input path="address"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="_eventId_submitStudInfo" value="Submit"/></td>
</tr>
</table>
</sf:form>
tiles.xml
<tiles-definitions>
<definition name="mainLayout" template="/WEB-INF/jsp/layout/mainLayout.jsp">
<put-attribute name="Title" value=""/>
<put-attribute name="Header" value="/WEB-INF/jsp/layout/Header.jsp"/>
<put-attribute name="Body" value=""/>
<put-attribute name="Footer" value="/WEB-INF/jsp/layout/Footer.jsp"/>
</definition>
<definition name="login" extends="mainLayout">
<put-attribute name="Title" value="Start Page"></put-attribute>
<put-attribute name="Body" value="/WEB-INF/flow/login.jsp"/>
</definition>
<definition name="studentReg" extends="mainLayout">
<put-attribute name="Title" value="Registration Page"></put-attribute>
<put-attribute name="Body" value="/WEB-INF/flow/StudentReg.jsp"/>
</definition>
</tiles-definitions>
但是每当我点击login.jsp的提交按钮时,它都会提供$ {flowExecutionUrl}&amp; $ {flowExecutionKey}为空白,未显示下一个屏幕。我错过了一些配置或出了什么问题?请帮忙。
答案 0 :(得分:0)
@Aasif您的配置&#39;看起来&#39;精细。众所周知,SWF对于排除故障是不直观的。尝试在您的流程中插入记录器,如下所示:
并确定&#39;流动的位置&#39;执行正在中断。一旦你隔离了位置。尝试进入流程代码...我怀疑正在吞下一个异常。
可能答案:
如果我不得不猜测(即使您的配置看起来正确)。我怀疑SWF / tiles不会解析视图名称&#39; studentReg&#39;。尝试通过创建单独的流来隔离此案例,并查看是否可以导航到视图studentReg。您还可以进入Tiles解析器逻辑以确保它被定位。
另外:
在我看来,为viewStateId,transition和viewName(即&#39; studentReg&#39;)提供相同的名称是不好的做法。我认为当出现这样的问题时,它会使问题变得更加困难。最好为它们添加后缀。 (即studentRegVsId,studentRegViewName等...)创建区别。