Spring mvc SpringWebFlow-JSF-PrimeFaces集成:UrlBasedViewResolver在JSF操作中添加了错误的URL

Spring mvc SpringWebFlow-JSF-PrimeFaces集成:UrlBasedViewResolver在JSF操作中添加了错误的URL,spring-mvc,facelets,spring-webflow-2,spring-faces,Spring Mvc,Facelets,Spring Webflow 2,Spring Faces,UrlBasedViewResolver前缀多次附加到URL,以便找不到资源。 Spring版本:4.2.0。发布Spring Web流版本: 2.4.2.2发布PrimeFaces:5.2JSF(JSFAPI和JSF impl):2.2.12 SpringWebFlowConfig.java @Configuration public class WebConfig{ @Autowired private SpringWebFlowConfig webFlowConf

UrlBasedViewResolver前缀多次附加到URL,以便找不到资源。

Spring版本:4.2.0。发布Spring Web流版本: 2.4.2.2发布PrimeFaces:5.2JSF(JSFAPI和JSF impl):2.2.12

SpringWebFlowConfig.java

@Configuration
    public class WebConfig{

    @Autowired
    private SpringWebFlowConfig webFlowConfig;


    @Bean
    public FlowHandlerMapping flowHandlerMapping() {
        FlowHandlerMapping mapping = new FlowHandlerMapping();
        mapping.setOrder(1);
        mapping.setFlowRegistry(this.webFlowConfig.flowRegistry());
        mapping.setDefaultHandler(new UrlFilenameViewController());
        return mapping;
    }

    @Bean
    public FlowHandlerAdapter flowHandlerAdapter() {
        JsfFlowHandlerAdapter adapter = new JsfFlowHandlerAdapter();
        adapter.setFlowExecutor(this.webFlowConfig.flowExecutor());
        adapter.setSaveOutputToFlashScopeOnRedirect(true);
        return adapter;
    }


    @Bean
    public UrlBasedViewResolver faceletsViewResolver() {
        UrlBasedViewResolver resolver = new UrlBasedViewResolver();
        resolver.setViewClass(JsfView.class);
        resolver.setPrefix("/WEB-INF/jsfaces/");
        resolver.setSuffix(".xhtml");
        return resolver;
    }



    @Bean
    public SimpleControllerHandlerAdapter simpleControllerHandlerAdapter() {
        return new SimpleControllerHandlerAdapter();
    }


}
@Configuration
public class SpringWebFlowConfig extends AbstractFacesFlowConfiguration{

    @Bean
    public FlowExecutor flowExecutor() {
        return getFlowExecutorBuilder(flowRegistry())
                .addFlowExecutionListener(new FlowFacesContextLifecycleListener())
                .addFlowExecutionListener(new SecurityFlowExecutionListener())
                //.addFlowExecutionListener(persistenceListener())
                .build();
    }


   @Bean
    public FlowDefinitionRegistry flowRegistry() {
        return getFlowDefinitionRegistryBuilder(flowBuilderServices())
                .setBasePath("/WEB-INF/flows")
                .addFlowLocationPattern("/**/*-flow.xml")
                .build();
    }


    @Bean
    public FlowBuilderServices flowBuilderServices() {
        return getFlowBuilderServicesBuilder().setDevelopmentMode(true).build();
    }

}
faces config.xml

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">

       <application>
        <message-bundle>/messages/JsfMessageResources</message-bundle>
       </application> 


    <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    </application>

</faces-config>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:faces="http://www.springframework.org/schema/faces"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">



    <mvc:annotation-driven />


    <context:component-scan base-package="com.efacec.oms.powr.controller" />  

    <mvc:resources mapping="/app/resources/**" location="/resources/" />
    <mvc:default-servlet-handler />
</beans>



**Folder Structure**

WEB-INF
 -- flows -->account-flow.xml    test-flow.xml welcome-flow.xml
 -- jsfaces  --> accountHome.xml   welcome.xhtml   testFlow.xml
 -- templates  --> general.xhtml

**welcome-flow.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">

    <var name="user" class="com.domain.UserEntity"/>


    <view-state id="welcome"  view="welcome.xhtml" model="user">
        <transition on="signOn" to="authentication">
        </transition> 
    </view-state>


    <action-state id="authentication"> 
        <evaluate expression="userService.authenticate(user)" />
        <transition on="success" to="finish" />
        <transition on="failure" to="welcome" />
    </action-state>


    <end-state id="finish" view="externalRedirect:account" /> 

</flow>
<?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">



    <var name="uiUtils" class="com.jsf.utils.UIUtils"/>


    <view-state id="account" view="accountHome.xhtml">
    </view-state>

</flow>

我看到您使用的是JSF2.2,而不是JSF2.0/2.1。我可以想象为什么您希望在JSF2.0/2.1上使用SpringWebFlow,但是在JSF2.2上看到它是很奇怪的,因为JSF版本带有内置流特性。你知道吗?JavaEE7教程:顺便说一句,尝试将SpringMVC与PrimeFaces混合使用是很可怕的。值得一读:应用程序需要提供rest服务(spring),后端完全由spring配置,我希望在前端使用JSF。我看到您使用的是JSF2.2,而不是JSF2.0/2.1。我可以想象为什么您希望在JSF2.0/2.1上使用SpringWebFlow,但是在JSF2.2上看到它是很奇怪的,因为JSF版本带有内置流特性。你知道吗?JavaEE7教程:顺便说一句,尝试将SpringMVC与PrimeFaces混合使用是很可怕的。阅读食物:应用程序需要提供rest服务(spring),后端完全由spring配置,我希望在前端使用JSF。
<?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">



    <var name="uiUtils" class="com.jsf.utils.UIUtils"/>


    <view-state id="account" view="accountHome.xhtml">
    </view-state>

</flow>
<p:commandButton id="submitButton" action="signOn"
                    value="Sign In" />
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.faces.FacesException: **/WEB-INF/jsfaces/WEB-INF/jsfaces/**welcome.xhtml Not Found in ExternalContext as a Resource
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
    com.efacec.oms.powr.filter.TokenAuthenticationFilter.doFilter(TokenAuthenticationFilter.java:89)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)