我正在使用 spring in(spring mvc+spring webflow)+jsf 2+JPA+Hibernate 开发一个项目,并且对映射 spring mvc (DispatcherServlet) 的请求有问题
我的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
id="WebApp_ID" version="3.0">
<display-name>AirTour</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<!-- SPRING -->
<!-- El contexloaderlistener es usado para iniciar el contexto de spring (sin mvc) para usar hibernete, jpa.... -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/conf/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- SPRING MVC & WEBFLOW -->
<!-- Este servlet es utiizado para el contexto web de spring, es decir para la parte web de spring mvc -->
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/conf/webflow-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Este servlet se utilizara cuando se utilicen rutas /app/* -->
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
<!-- JSF -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
我了解这个 web.xml 以 .xhtml 终止的请求由 jsf servlet 管理,而具有模式 /app/* 的请求由 dispatcherSevler (spring mvc) 管理。很好?
我的 index.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<h:dataTable value="#{gestorUsuarios.listar()}" var="usuarios">
<h:column>
<f:facet name="header">
<h:outputText value="Nombre" />
</f:facet>
<h:outputText value="#{usuarios.nombre}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Apellidos" />
</f:facet>
<h:outputText value="#{usuarios.apellidos}" />
</h:column>
</h:dataTable>
<h:link value="Registro" outcome="app/registro" />
</h:body>
</html>
但是当视图被渲染时,“Registro”链接不会显示,因为它已经与导航案例相关联。
我的 webflow-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces:resources />
<!--
Maps request paths to flows in the flowRegistry; e.g. a path of
/registration-flow looks for a flow with id "registration-flow"
-->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
</bean>
<!-- Gestiona las solicitudes provenientes de un flujo y elas procesa.
Es la conexión entre el dispacherServlet y webflow. Esta conectado con un
ejecutor de un flujo en aquellos fljos para los que se gestinan solicitudes
-->
<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<flow:flow-executor id="flowExecutor">
<flow:flow-execution-listeners>
<flow:listener ref="facesContextListener" />
</flow:flow-execution-listeners>
</flow:flow-executor>
<flow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<flow:flow-location-pattern value="/*-flow.xml" />
</flow:flow-registry>
<!-- Equivalente a org.springframework.webflow.mvc.servlet.FlowHandlerAdapter,
la gestiona solicitudes procedentes de un flujo y las procesas -->
<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<faces:flow-builder-services id="flowBuilderServices" development="true" />
<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />
我的项目。图片
http://i.stack.imgur.com/OLhDd.png
我需要 spring mvc 中的 viewResolver 吗?