Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法启动我的SpringWeb流_Spring_Jsp_Spring Mvc_Spring Webflow - Fatal编程技术网

无法启动我的SpringWeb流

无法启动我的SpringWeb流,spring,jsp,spring-mvc,spring-webflow,Spring,Jsp,Spring Mvc,Spring Webflow,我有一个使用SpringWebFlow的应用程序。这是我的web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.c

我有一个使用SpringWebFlow的应用程序。这是我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/root-context.xml</param-value>
    </context-param>

    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <welcome-file-list>
        <welcome-file>home.jsp</welcome-file>
    </welcome-file-list>
    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>*.action</url-pattern>
    </servlet-mapping>

</web-app>

上下文配置位置
/WEB-INF/spring/root-context.xml
org.springframework.web.context.ContextLoaderListener
appServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/spring/appServlet/servlet-context.xml
1.
home.jsp
appServlet
*.行动
servlet-context.xml中我的流的定义:

<beans:bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">

        <beans:property name="mappings">
        <beans:value>inicio.do=flowController</beans:value>
        </beans:property>
        <beans:property name="alwaysUseFullPath" value="true"></beans:property>
    </beans:bean>
    <beans:bean id="flowcontroller" class="org.springframework.webflow.mvc.servlet.FlowController">
    <beans:property name="flowExecutor" ref="flowExecutor"></beans:property>
    </beans:bean>
    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>
    <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices"> 
            <webflow:flow-location id="inicio" path="/WEB-INF/flujos/flujo.xml"/> 
    </webflow:flow-registry>   
    <webflow:flow-builder-services id="flowBuilderServices" 
            view-factory-creator="viewFactoryCreator"/>
            <beans:bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
            <beans:property name="viewResolvers">
            <beans:list>
                <beans:ref bean="viewResolver"/>
            </beans:list>
            </beans:property>
            </beans:bean>
     <beans:bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
        <beans:property name="flowExecutor" ref="flowExecutor"></beans:property>
     </beans:bean>

inicio.do=流量控制器
该流与另一个JSP关联,并带有重定向。当用户单击应该指向流的链接时,会调用“startflow.jsp”,它会重定向到流,如下所示:

<c:redirect url="inicio.do"></c:redirect> 


现在,我收到一个404错误页面,说myapp/inicio.do不可用。我做错了什么?有人能帮我吗?谢谢。

您的dispatcher servlet AppServlet已映射到*.action(请参阅web.xml中的.action扩展名),其中与SimpleUrlHandlerMapping中一样,您映射到了inicio.do

这就是它的工作原理:

1) 服务器根据请求url和web.xml中的servlet映射知道哪个servlet应该处理请求

2) DispatcherServlet接收请求,它检查HandlerMapping并调用与请求关联的控制器

3) 如果定义了FlowController,dispactherServlet将根据处理程序映射配置向其委托请求

但是没有与您的请求匹配的servletmapping,因为没有到*.do的映射

因此,将重定向更改为:

    <c:redirect url="/inicio.action"></c:redirect> 

并映射到:

    <beans:value>inicio.action=flowController</beans:value>
inicio.action=flowController

是的……当我在我的应用程序中遇到其他类型的问题时,我正在考虑这样做。你刚刚证实了我的想法。当然,它是有效的。非常感谢你,普拉萨德。