JSF 2 + Spring 3:无法让它工作

时间:2012-08-09 02:40:36

标签: spring jsf spring-mvc

我真的无法解决这个问题。 首先,我从STS创建了一个Spring模板项目(Spring MVC)。

然后我完全复制了http://blog.terrencemiao.com/archives/spring-3-shacks-up-jsf-2-the-maverick-way处报告的代码,但它对我不起作用。

我认为该代码中至少有一个错误,即“applicationConfigure.xml应该是applicationContext.xml”。我纠正了它,但它还没有用。

除了在该网站上报告的文件(相同的结构),我有:

(1)root-context(WEB-INF / spring)

<?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:faces="http://www.springframework.org/schema/faces"
 xmlns:mongo="http://www.springframework.org/schema/data/mongo"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
                    http://www.springframework.org/schema/mvc
                    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
                    http://www.springframework.org/schema/faces
                    http://www.springframework.org/schema/faces/spring-faces-2.2.xsd
                    http://www.springframework.org/schema/context
                    http://www.springframework.org/schema/context/spring-context-3.1.xsd
                ">  
<!-- Root Context: defines shared resources visible to all other web components -->

(2)servlet-context(WEB-INF / spring / appServlet)

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"     
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     
xmlns:beans="http://www.springframework.org/schema/beans"     
xmlns:context="http://www.springframework.org/schema/context"     
xsi:schemaLocation="http://www.springframework.org/schema/mvc     
http://www.springframework.org/schema/mvc/spring-mvc-3.0.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">

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="org.paradise.sandbox" />

==============================

其余的完全相同。不幸的是,当我启动服务器并打开localhost:8080 / HelloSpring / helloSpring时,我收到以下错误:

  

SEVERE:Servlet [DispatcherServlet]的Servlet.service()在路径[/ HelloSpring]的上下文中抛出异常[Circular view path [helloSpring]:将再次调度回当前的处理程序URL [/ HelloSpring / helloSpring]。检查您的ViewResolver设置! (提示:由于默认视图名称生成,这可能是未指定视图的结果。)]具有根本原因   javax.servlet.ServletException:循环视图路径[helloSpring]:将再次调度回当前处理程序URL [/ HelloSpring / helloSpring]。检查您的ViewResolver设置! (提示:由于默认的视图名称生成,这可能是未指定视图的结果。)       在org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:292)       在org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:214)       在org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)       在org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)       在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)       在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)       在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)       在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)       在javax.servlet.http.HttpServlet.service(HttpServlet.java:621)       在javax.servlet.http.HttpServlet.service(HttpServlet.java:722)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)       在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)       在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)       在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)       在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)       在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)       at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.traceNextValve(HttpRequestOperationCollectionValve.java:116)       at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:98)       在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)       在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)       at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:565)       at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run(JIoEndpoint.java:307)       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:603)       在java.lang.Thread.run(Thread.java:722)

1 个答案:

答案 0 :(得分:1)

它不起作用,因为您的InternalViewResolver正在“/ WEB-INF / views /”下查找helloSpring.jsp文件,而您拥有的文件是helloSpring.xhtml。

您可以将后缀更改为值“.xhtml”或使用.jsp视图文件。