Spring 3与Thymeleaf配置问题

时间:2012-10-27 21:24:57

标签: spring thymeleaf

您好我的构建路径中有以下jar -

弹簧豆-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>

我在启动时遇到的错误是 -

找不到ServletContext资源[/WEB-INF/springMVC-servlet.xml]中定义的名为'templateResolver'的bean的类[org.thymeleaf.templateresolver.ServletContextTemplateResolver];嵌套异常是java.lang.ClassNotFoundException:org.thymeleaf.templateresolver.ServletContextTemplateResolver 我在这里错过了其他图书馆吗?非常感谢任何帮助。

1 个答案:

答案 0 :(得分:4)

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

从这里下载jar

thymeleaf download site