试图将JSF添加到我的Spring

试图将JSF添加到我的Spring

本文介绍了试图将JSF添加到我的Spring WebFlow项目中,现在我的WebFlow无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些JSF添加到我的Spring WebFlow项目中,并且尝试按照以下详细信息进行了一些更改:

I am trying to add some JSF to my Spring WebFlow project and I made some changes trying to following the details at:

http://static.springsource. org/spring-webflow/docs/2.3.x/reference/html/ch13s07.html

但是现在我的webflow项目将无法正常工作.

but now my webflow project will not work.

这是我的旧flow.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"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:context="http://www.springframework.org/schema/context"
 xsi:schemaLocation="http://www.springframework.org/schema/webflow-config
   http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.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">

<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />

  <!-- Executes flows: the entry point into the Spring Web Flow system -->
  <flow:flow-executor id="flowExecutor" />

  <!-- The registry of executable flow definitions -->
  <flow:flow-registry id="flowRegistry"
           flow-builder-services="flowBuilderServices"
           base-path="/WEB-INF/flows">
     <flow:flow-location-pattern value="/**/*-flow.xml" />
  </flow:flow-registry>


 <flow:flow-builder-services id="flowBuilderServices"
           view-factory-creator="mvcViewFactoryCreator"
           validator="validator"
           />


  <bean id="mvcViewFactoryCreator" class=
      "org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
     <property name="defaultViewSuffix" value=".jsp" />
  </bean>

  <!--Maps request paths to flows in the flowRegistry-->
  <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry" />
  </bean>

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

</beans>

现在这是我无法使用的新flow.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: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-3.0.xsd
        http://www.springframework.org/schema/webflow-config
        http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
        http://www.springframework.org/schema/faces
        http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">

    <!-- Executes flows: the central entry point into the Spring Web Flow system -->
    <webflow:flow-executor id="flowExecutor">
        <webflow:flow-execution-listeners>
            <webflow:listener ref="facesContextListener"/>
        </webflow:flow-execution-listeners>
    </webflow:flow-executor>

    <!-- The registry of executable flow definitions -->
    <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
        <webflow:flow-location-pattern value="**/*-flow.xml" />
    </webflow:flow-registry>

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

    <!-- A listener maintain one FacesContext instance per Web Flow request. -->
    <bean id="facesContextListener"
        class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />

</beans>

,现在是我的faces-config.xml文件:

<?xml version='1.0' encoding='UTF-8'?>
<faces-config 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-facesconfig_2_0.xsd"
    version="2.0">

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

</faces-config>

所以有人可以告诉我为什么Webflow停止工作!

推荐答案

我认为您正在尝试将Faces-config.xml作为Spring配置文件加载.您可以在JSF配置文件(faces-config.xml)中注册JSF应用程序的资源,它不是Spring配置文件,因此请勿将其包含在其他Spring配置文件中.同样,/WEB-INF文件夹是放置faces-config.xml的默认位置.如果您将它放在/WEB-INF/spring文件夹中,则需要在web.xml中提及如下路径:

I think you are trying to load faces-config.xml as a Spring configuration file. The JSF configuration file (faces-config.xml) is where you register a JSF application's resources and it is not a Spring configuration file so do not include it with other Spring config files.Also /WEB-INF folder is the default place to put faces-config.xml. If you have it in /WEB-INF/spring folder then you need to mention the path in the web.xml something like this:

<context-param>
  <param-name>javax.faces.CONFIG_FILES</param-name>
  <param-value>
   /WEB-INF/faces/faces-config.xml
  </param-value>
</context-param>

与具体问题无关,您还需要在faces-config.xml中使用"SpringBeanFacesELResolver"来解析任何Spring bean,然后再将其注入任何JSF托管bean中.

Unrelated to the concrete issue you also need 'SpringBeanFacesELResolver' in your faces-config.xml to resolve any Spring beans before you inject them in any JSF managed beans.

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

这篇关于试图将JSF添加到我的Spring WebFlow项目中,现在我的WebFlow无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:13