0

春の速度構成、いくつかの構成がありません。なぜそうなるのか教えてください。URLにアクセスすると、以下のエラーが発生します。

SEVERE: Servlet.service() for servlet springDispatcher threw exception
org.springframework.core.NestedIOException: Cannot find Velocity template for URL [layout.vm]: Did you specify the correct resource loader path?; nested exception is org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'layout.vm'
at org.springframework.web.servlet.view.velocity.VelocityLayoutView.checkResource(VelocityLayoutView.java:133)
at org.springframework.web.servlet.view.UrlBasedViewResolver.loadView(UrlBasedViewResolver.java:438)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:186)
at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:401)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:103)
at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1211)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1160)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)

spring-context.xml

<bean id="velocityConfig"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/velocity/" />
</bean>

<!-- View resolvers can also be configured with ResourceBundles or XML files. 
If you need different view resolving based on Locale, you have to use the 
resource bundle resolver. -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".vm" />
</bean>

速度構成がドロップされると、以下の例外が発生します。

org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.springframework.web.servlet.view.velocity.VelocityConfig] is defined: expected single bean but found 0
at org.springframework.beans.factory.BeanFactoryUtils.beanOfTypeIncludingAncestors(BeanFactoryUtils.java:367)
at org.springframework.web.servlet.view.velocity.VelocityView.autodetectVelocityEngine(VelocityView.java:239)
at org.springframework.web.servlet.view.velocity.VelocityView.initApplicationContext(VelocityView.java:225)
at org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:119)
at org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:72)
at org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:73)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:117)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:92)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:394)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1448)
at org.springframework.beans.fact
4

2 に答える 2

1

私が間違っていなければ、あなたはあなたviewResolverだけを使ってVelocity設定を達成することができるでしょう。

プレフィックスをresourceLoaderPathに記載されているものに変更すると、問題ないはずです(自分でテストしませんでした)

<property name="prefix"><value>/WEB-INF/velocity/</value></property>

また、velocityConfigタグを完全に削除することもできます。

于 2012-10-29T18:09:26.843 に答える
-2

あなたが使用する必要があります

(bean id="ViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver")

いいえ

(bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver")

この Bean は「layout.vm」を使用します。私もこの問題を抱えています。

于 2016-02-05T02:19:25.000 に答える