瓷砖不起作用,抛出异常

时间:2014-12-19 06:30:03

标签: spring-mvc

的pom.xml

<properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
        <cglib.version>2.2.2</cglib.version>
        <tiles-version>3.0.1</tiles-version>
    </properties>


<!-- TILES -->
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>${tiles-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-api</artifactId>
        <version>${tiles-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>${tiles-version}</version>
    </dependency>

servlet的context.xml中

<!-- TILES -->
    <beans:bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
           ` <beans:property name="viewClass">`
                <beans:value>
                   org.springframework.web.servlet.view.tiles3.TilesView
               </beans:value>`
          </beans:property>`
        </beans:bean>

<beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
       ` <beans:property name="definitions">
           <beans:list>
                <beans:value>/WEB-INF/tiles.xml</beans:value>
            </beans:list>
        </beans:property>
    </beans:bean>

tiles.xml

<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
   "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>

<definition name="base" template="/WEB-INF/views/layout.jsp">
    <put-attribute name="header" value="/WEB-INF/views/header.jsp" />
    <put-attribute name="body" value="" />
</definition>

<definition name="route/home" extends="base">
    <put-attribute name="body" value="/WEB-INF/views/hello.jsp" />
</definition>

</tiles-definitions>

引发例外

>     HTTP Status 500 - Servlet.init() for servlet appServlet threw exception
>     org.springframework.beans.factory.BeanCreationException: Error creating bean with name
> 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0':
> Initialization of bean failed; nested exception is
> org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
> find class
> [org.springframework.web.servlet.view.tiles3.TilesConfigurer] for bean
> with name 'tilesConfigurer' defined in ServletContext resource
> [/WEB-INF/spring/appServlet/servlet-context.xml]; nested exception is
> java.lang.ClassNotFoundException:
> org.springframework.web.servlet.view.tiles3.TilesConfigurer
>     Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
> find class
> [org.springframework.web.servlet.view.tiles3.TilesConfigurer] for bean
> with name 'tilesConfigurer' defined in ServletContext resource
> [/WEB-INF/spring/appServlet/servlet-context.xml]; nested exception is
> java.lang.ClassNotFoundException:
> org.springframework.web.servlet.view.tiles3.TilesConfigurer
>       org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)

请帮忙。感谢。

1 个答案:

答案 0 :(得分:1)

您使用的是Spring 3.1.1,它没有org.springframework.web.servlet.view.tiles3.TilesConfigurer类。

考虑升级到Spring 3.2.0或更高版本。或者降级到Tiles 2,Spring 3.1.1支持。

参考文献: