【问题标题】:trying to add JSF to my Spring WebFlow Project and now my WebFlow will not working试图将 JSF 添加到我的 Spring WebFlow 项目中,现在我的 WebFlow 将无法工作
【发布时间】:2012-10-14 13:46:26
【问题描述】:

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

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

但现在我的 webflow 项目将无法运行。

这是我的旧 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 停止工作了!!

【问题讨论】:

    标签: spring-mvc jsf-2 spring-webflow


    【解决方案1】:

    我认为您正在尝试将 faces-config.xml 作为 Spring 配置文件加载。 JSF 配置文件 (faces-config.xml) 是您注册 JSF 应用程序资源的地方,它不是 Spring 配置文件,因此不要将其包含在其他 Spring 配置文件中。 此外,/WEB-INF 文件夹是放置 faces-config.xml 的默认位置。如果您在 /WEB-INF/spring 文件夹中有它,那么您需要在 web.xml 中提及路径,如下所示:

    <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。

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

    【讨论】:

    • 您是否遇到任何异常并且不要更改问题中的代码。放置一个更新部分并添加您更改的内容。
    • 我没有得到任何例外,但页面不显示
    • 你能把你的applicationContext也发一下吗
    猜你喜欢
    • 2012-10-14
    • 1970-01-01
    • 1970-01-01
    • 2012-09-03
    • 2015-07-25
    • 2013-08-30
    • 2012-09-16
    • 2012-11-18
    • 2020-10-15
    相关资源
    最近更新 更多