DispatcherServlet不映射请求

时间:2012-12-22 14:11:53

标签: spring spring-mvc jsf-2

我正在使用spring in(spring mvc + spring webflow)+ jsf 2 + JPA + Hibernate开发一个项目,并且映射sp​​ring 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管理,而带有pattern / 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?

0 个答案:

没有答案