您可以在屏幕截图异常和web.xml文件中看到配置tiles-defs.xml。
但我无法理解瓷砖有什么问题?是不是web.xml tile配置错了?感谢您的关注。
的web.xml
<context-param>
<param-name>
org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</context-param>
瓦片-defs.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="homepage" template="/view/layouts/home.jsp">
<put-attribute name="cssPaths" value="/view/tiles/common/cssPaths.jsp"/>
<put-attribute name="metas" value="/view/tiles/common/metas.jsp"/>
<put-attribute name="header" value="/view/tiles/common/header.jsp"/>
<put-attribute name="footer" value="/view/tiles/common/footer.jsp"/>
<put-attribute name="sliders" value="/view/tiles/common/sliders.jsp"/>
<put-attribute name="featureditems" value="/view/tiles/common/featureditems.jsp"/>
<put-attribute name="scripts" value="/view/tiles/common/scripts.jsp"/>
<put-attribute name="brands" value="/view/tiles/common/brands.jsp"/>
</definition>
</tiles-definitions>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>ecommerce</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>ecommerce Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.24</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<build>
<finalName>ecommerce</finalName>
</build>
</project>
异常
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 14
11: <title>Urunler</title>
12: </head>
13: <body>
14: <tiles:insertDefinition name="homepage"/>
15: </body>
16: </html>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.NullPointerException
org.apache.tiles.access.TilesAccess.getContainer(TilesAccess.java:124)
org.apache.tiles.access.TilesAccess.getContainer(TilesAccess.java:107)
org.apache.tiles.access.TilesAccess.getCurrentContainer(TilesAccess.java:174)
org.apache.tiles.template.InsertDefinitionModel.execute(InsertDefinitionModel.java:95)
org.apache.tiles.jsp.taglib.InsertDefinitionTag.doTag(InsertDefinitionTag.java:254)
org.apache.jsp.index_jsp._jspx_meth_tiles_005finsertDefinition_005f0(index_jsp.java:93)
org.apache.jsp.index_jsp._jspService(index_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.
Apache Tomcat/6.0.29
答案 0 :(得分:1)
关于Configuring Tiles in your web application,它提到如下: -
<dependency>
<groupId>org.apache.tiles</groupId>
<artefactId>tiles-extras</artefactId>
<version>3.0.1</version>
</dependency>
在web.xml文件中使用适当的侦听器加载tiles容器。
<listener>
<listener-class>
org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
</listener-class>
</listener>
<servlet>
<servlet-name>Tiles Dispatch Servlet</servlet-name>
<servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Tiles Dispatch Servlet</servlet-name>
<url-pattern>*.tiles</url-pattern>
</servlet-mapping>
AFAIU,我们应该配置listener
和/或Tiles Dispatch Servlet
来启动Tiles引擎。请通过以下链接查看更多信息: -