spring with spring:getting error - java.lang.ClassNotFoundException:org.apache.tiles.TilesApplicationContext

Bhe*_*aar 8 spring apache-tiles maven

我是春天的新手,并试图在春天使用瓷砖.但是犯了错误.我在我的项目中使用maven.我也尝试过更改版本,但没有用.以下是项目内容:

的pom.xml

  <!-- Apache Tiles -->
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>3.0.5</version>
    </dependency>

    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>3.0.5</version>
    </dependency>

     <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-api</artifactId>
        <version>3.0.5</version>
    </dependency>
     <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-servlet</artifactId>
        <version>3.0.5</version>
    </dependency>
     <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-template</artifactId>
        <version>3.0.5</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

servlet的context.xml中

  <!-- for Tiles -->
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="viewResolver">  
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>            
</bean>

<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" id="tilesConfigurer">  
    <property name="definitions" value="/WEB-INF/tiles-definitions.xml" />           
</bean>
Run Code Online (Sandbox Code Playgroud)

瓷砖-definitions.xml中

  <?xml version="1.0" encoding="UTF-8"?>
<tiles-definitions>  
    <definition name="base.definition" template="/WEB-INF/views/tilesMainTemplate.jsp">  
        <put-attribute name="title" value=""></put-attribute>  
        <put-attribute name="header" value="/WEB-INF/views/header.jsp"></put-attribute>  
        <put-attribute name="menu" value="/WEB-INF/views/home.jsp"></put-attribute>  
        <put-attribute name="body" value=""></put-attribute>  
        <put-attribute name="footer" value="/WEB-INF/views/footer.jsp"></put-attribute>  
    </definition>  

    <definition extends="base.definition" name="saveAd">  
        <put-attribute name="title" value="Post your free Ad"></put-attribute>  
        <put-attribute name="body" value="/WEB-INF/views/adSave.jsp"></put-attribute>  
    </definition>  


</tiles-definitions>  
Run Code Online (Sandbox Code Playgroud)

然后有tilesMainTemplate,页眉和页脚jsp的,我不认为有任何问题.任何有关这方面的帮助将受到高度赞赏,在此先感谢.

Bhe*_*aar 18

最后它奏效了!我将tile3替换为tiles3,正如mck正确指出的那样,并将以下行添加到tiles-definitions.xml

<!DOCTYPE tiles-definitions PUBLIC
  "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" 
  "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
Run Code Online (Sandbox Code Playgroud)


小智 11

在servlet-context.xml中,您使用的是tiles2 spring-tiles集成类.

请改为使用org.springframework.web.servlet.view.tiles3下的类