不支持的视图类型/WEB-INF/index.xhtml此FlowViewResolver实现仅支持的类型为[.jsp]和[.jspx]

问题描述 投票:0回答:1

我们对Spring-webflow配置和视图重定向有问题。

登录后,您应进入已配置的主页,但是您将处于重定向循环中,进入错误页面。

[检查日志跟踪,确认您在登录名中提交时将其重定向到相应的视图,但是控制该视图且仅允许使用jsp和jspx的spring组件发生错误。

我们正在使用Spring-webflow 2.4.1,Spring-mvc 3.1.4,jsf 2.2和primefaces 4.0。

由于它是一个旧的应用程序,因此我们一直在验证使用xml的不同方法,并且我们正在做的工作是从ant重构为maven,以便进行所需的修改。

生成的错误如下:

11:15:32,603信息[标准输出](http-localhost / 127.0.0.1:8080-5)10-06-2020 11:15:32,602 [DEBUG] [http-localhost / 127.0.0.1:8080-5] [org.springframework.webflow.engine.impl.FlowExecutionImpl]试图处理[org.springframework.webflow.execution.FlowExecutionException:异常根源为[java.lang。]。 IllegalArgumentException:不支持的视图类型/WEB-INF/index.xhtml此FlowViewResolver实现仅支持的类型为[.jsp]和[.jspx]] 11:15:32,603错误[com.axa.ca.caem.web.core.exception.CaemExceptionHandler](http-localhost / 127.0.0.1:8080-5)处理异常 11:15:32,603 INFO [stdout](http-localhost / 127.0.0.1:8080-5)10-06-2020 11:15:32,603 [ERROR] [http-localhost / 127.0.0.1:8080-5] [com .axa.ca.caem.web.core.exception.CaemExceptionHandler]处理异常 11:15:32,604错误[com.axa.ca.caem.web.core.exception.CaemExceptionHandler](http-localhost / 127.0.0.1:8080-5)CaemExceptionHandler中捕获了未知错误:java.lang.IllegalArgumentException:不支持的视图类型/WEB-INF/index.xhtml此FlowViewResolver实现仅支持的类型为[.jsp]和[.jspx] 在org.springframework.webflow.mvc.builder.FlowResourceFlowViewResolver.getViewInternal(FlowResourceFlowViewResolver.java:94)[spring-webflow-2.4.1.RELEASE.jar:2.4.1.RELEASE]

配置文件为:spring-webflow.xml

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

    <faces:resources/>

    <!-- Maps request paths to flows in the flowRegistry; localeChangeInterceptor 
    is used for intercepting internationalization changes -->
    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry" />
        <property name="interceptors">
            <list>
                <ref bean="localeChangeInterceptor"></ref>
            </list>
        </property>
        <property name="order" value="0"/>
    </bean>

    <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor" />
    </bean>

    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
        <webflow:flow-execution-listeners>
            <webflow:listener ref="facesContextListener"/>
            <webflow:listener ref="securityListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor> 

    <!-- Registramos todos nuestros flujos con la dupla id-xml -->
    <webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows">  
        <webflow:flow-location-pattern value="/**.xml" />
        <webflow:flow-location id="parent-flow" path="parent-flow.xml" />
    </webflow:flow-registry>  

    <webflow:flow-builder-services id="flowBuilderServices" />  

    <!-- Mapea a nombres logicos de vista to recursos fisicos -->
    <!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' to '/WEB-INF/search.xhtml' -->
    <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".xhtml" />
    </bean>

    <!-- A listener to create and release a FacesContext -->
    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>

</beans>

提前感谢。

spring jsf spring-webflow
1个回答
0
投票

这对我来说是正确的配置。谢谢!

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

    <faces:resources/>

    <!-- Spring Webflow central configuration component -->
    <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
        <webflow:flow-execution-listeners>          
            <webflow:listener ref="facesContextListener"/>          
            <webflow:listener ref="securityListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor>

    <!-- Installs a listener that creates and releases the FacesContext for each request. -->   
    <bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>   

    <webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices" 
        base-path="/WEB-INF/flows/" >
        <webflow:flow-location-pattern value="/**.xml" />
        <webflow:flow-location id="parent-flow" path="parent-flow.xml" />
    </webflow:flow-registry>

    <!-- Configures the Spring Web Flow JSF integration --> 
    <faces:flow-builder-services id="facesFlowBuilderServices" development="true" />

    <bean id="mvcViewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
        <property name="viewResolvers">
            <list>
                <ref bean="viewResolver"/>
            </list>
        </property>     
    </bean>

    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver">
          <property name="prefix" value="/WEB-INF/views/"/>
          <property name="suffix" value=".xhtml" />
    </bean>

    <!-- Dispatches requests mapped to flows to FlowHandler implementations --> 
    <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">      
        <property name="flowExecutor" ref="flowExecutor" /> 
    </bean>

    <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="flowRegistry" ref="flowRegistry"/>
        <property name="order" value="1"/>
    </bean>

</beans>
© www.soinside.com 2019 - 2024. All rights reserved.