以下是我的项目网址。 http://localhost:8080/springwebflow/loginFlow;jsessionid=k7338gzuvyc2sk36axkzhe9r?execution=e1s1
springwebflow / loginFlow 路径如何运作?用这条路径我的display_login.jsp怎么来?
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Spring Web Flow</display-name>
<servlet>
<servlet-name>login</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/config/login-servlet-config.xml
/WEB-INF/config/login-webflow-config.xml
/WEB-INF/config/spring-config.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>login</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
的web.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
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">
<mvc:annotation-driven />
<context:component-scan base-package="com.studytrails.tutorials.springwebflow" />
<!--Define FlowHandlerMapping to tell DispatcherServlet (in web.xml)
to send flow requests to Spring Web Flow -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="loginFlowRegistry" />
</bean>
<!-- Define FlowHandlerAdapter to handle Spring Web Flow request call.
This is the Controller class in Spring Web Flow -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="loginFlowExecutor" />
</bean>
</beans>
登录-servlet的config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:flow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Define the flow executor responsible for executing login web flow -->
<flow:flow-executor id="loginFlowExecutor" flow-registry="loginFlowRegistry"/>
<!-- Define the registry that holds references to all the flow related XML configuration-->
<flow:flow-registry id="loginFlowRegistry">
<flow:flow-location id="loginFlow" path="/WEB-INF/flows/login-flow.xml"/>
</flow:flow-registry>
</beans>
登录-的Webflow-config.xml中
<%@ page isELIgnored ="false" %>
<html xmlns:form="http://www.springframework.org/tags/form">
<body>
<form action="${flowExecutionUrl}&_eventId=loginCredentialsEntered" method="post">
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}"/>
<br/>
Enter login name as <b>alba</b> and password as <b>pass</b> for successfull login.
<br/>
Use any other login name and password for login error.
<br/>
<br/>
<table>
<tr>
<td>Login Name:</td>
<td><input type="text" name="loginName"/></td>
</tr>
<tr>
<td>Password: </td>
<td><input type="text" name="password"/></td>
</tr>
</table>
<br/>
<input type="submit" value="Login" />
</form>
</body>
</html>
display_login.jsp
PFA是我的文件,请您解释一下流量如何与网址一起使用。
答案 0 :(得分:0)
因此,如果我理解了您的问题,您希望使用流程显示您的jsp。 Normaly,我们使用这样的层次结构:
VUE
-src /主/ JAVA
-controllers
-src /主/资源
-Meta-INF
-flows
-page文件夹
-page-flow.xml
-resources
-page文件夹
-page.xhtml
每个文件夹都有一个file.xml,你可以添加一个subFolder,然后把你的xml放在上面。 对于你的流程,它应该是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<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"
parent="default">
<view-state id="myPage" view="/page-folder/page.xhtml">
<on-entry>
<evaluate expression="pageController.init()"></evaluate>
</on-entry>
<transition on="cancel" to="close"/>
</view-state>
</flow>
如果你想知道如何使用spring flow渲染视图: https://spring.io/blog/2007/11/15/the-spring-web-flow-2-0-vision
如果查看官方文档,情况会更好。
答案 1 :(得分:0)
首先,您可以添加通配符模式以指示(流位置模式),该模式将创建有关如何注册流的规则。这将使您能够使用1个规则注册多个流,而不是手动对每个流进行硬编码。 (注意:以下是注册流程的非官方“标准和最佳实践”方式)
<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows" flow-builder-services="flowBuilderServices">
<webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>
所以上述规则规定:
执行此操作后,您可以通过应用程序中任何位置映射到的URL导航到已注册的流。
使用示例流程:
/WEB-INF/flows/path/to/process1/reservation-flow.xml // note: ends in "-flow.xml"
可通过以下的http get请求访问:
http://(my-web-server-ip):(port)/path/to/process1
(注意:“flow”不包含在url路径中,因为我们将其设置为flow-registry定义中base-path =“/ WEB-INF / flows”属性的一部分,并注意流文件名在请求中根本不使用流中定义的目录)
有关详细信息,请参阅此答案:Webflow Flow Location By URI?