2012-10-27 110 views
0

你好,我有我的构建路径如下罐子 -春3 Thymeleaf配置问题

弹簧豆-3.1.2.RELEASE.jar
弹簧上下文3.1.2.RELEASE.jar
弹簧芯3.1.2.RELEASE.jar
弹簧表达-3.1.2.RELEASE.jar
弹簧网络3.1.2.RELEASE.jar
弹簧webmvc-3.1.2.RELEASE.jar
thymeleaf-spring3-2.0.13.jar

和我的servlet

<?xml version="1.0" encoding="UTF-8"?><br> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd"> 

    <context:component-scan base-package="web.controller" /> 

    <!-- Enabling Spring MVC configuration through annotations --> 
    <mvc:annotation-driven /> 

    <!-- Mapping Static Resources --> 
    <mvc:resources mapping="/resources/**" location="/resources/" /> 

    <bean id="templateResolver" class="org.thymeleaf.templateresolver.ServletContextTemplateResolver"> 
     <property name="prefix" value="/WEB-INF/views/" /> 
     <property name="suffix" value=".html" /> 
     <property name="templateMode" value="HTML5" /> 
    </bean> 

    <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine"> 
     <property name="templateResolver" ref="templateResolver" /> 
    </bean> 

    <bean class="org.thymeleaf.spring3.view.ThymeleafViewResolver"> 
     <property name="templateEngine" ref="templateEngine" /> 
     <property name="order" value="1" /> 
     <property name="viewNames" value="*.html" /> 
    </bean> 

</beans> 

我得到启动的错误是 -

找不到类[org.thymeleaf.templateresolver.ServletContextTemplateResolver]与名豆 'templateResolver' 在ServletContext的资源[定义/WEB-INF/springMVC-servlet.xml];嵌套异常是java.lang.ClassNotFoundException:org.thymeleaf.templateresolver.ServletContextTemplateResolver 我在这里是否缺少其他库?任何帮助深表感谢。

回答

4

您错过了实际的Thymeleaf罐子。你包含了提供集成的Spring jar,但是你错过了它的实际实现。

从这里下载

thymeleaf download site

+0

感谢坛子......我加thymeleaf-2.0.13.jar到构建路径。但得到了一个新的错误 - org.springframework.beans.factory.BeanCreationException:在ServletContext资源中定义的名称为'templateResolver'的bean时出错[/WEB-INF/springMVC-servlet.xml]:bean的实例化失败 – user1755645

+0

什么是堆栈跟踪?你可能会错过另一个罐子,或者其他许多问题。这也可能是一个版本问题。尝试用百里香网站的thymeleaf-spring3罐替换百里香叶spring3-2.0.13.jar。 – chrislhardin

+0

下载了软件包,错误消失了......谢谢 – user1755645