java - Spring 3 MVC + 磁贴 3 : Attribute "header" not found

标签 java spring jsp spring-mvc apache-tiles

我正在尝试使用 spring3mvctiles3 构建一个小型 Web 应用程序。当我启动应用程序时,出现如下错误:

org.apache.tiles.template.NoSuchAttributeException:找不到属性“header”。

我在之前的一些帖子中读到这可能是 .jsp 的 XML 路径的问题,但在我看来一切都很好。你能帮我解决这个问题吗?

tiles.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!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="tile.homepage" template="/index.jsp">
    <put-attribute name="title" value=""></put-attribute>
    <put-attribute name="header" value="/WEBINF/jsp/modules/tiles/t_header.jsp" ></put-attribute>
    <put-attribute name="body" value="/WEB-INF/jsp/modules/tiles/t_body_homepage.jsp" ></put-attribute>
    <put-attribute name="footer" value="/WEB-INF/jsp/modules/tiles/t_footer.jsp" ></put-attribute>
</definition>

index.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"pageEncoding="ISO-8859-1"%>
 <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
 <html>
 <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title><tiles:insertAttribute name="title" ignore="true" /></title>
    <tiles:insertAttribute name="header" />
 </head>
 <body>
    <div id="bodyHomePage">
      <tiles:insertAttribute name="body" />
      <div id="footer"><tiles:insertAttribute name="footer" /></div>
     </div>
 </body>
 </html>

错误:

org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.
org.apache.tiles.template.DefaultAttributeResolver.computeAttribute(DefaultAttributeResolver.java:50)
org.apache.tiles.template.InsertAttributeModel.resolveAttribute(InsertAttributeModel.java:165)
org.apache.tiles.template.InsertAttributeModel.execute(InsertAttributeModel.java:121)
org.apache.tiles.jsp.taglib.InsertAttributeTag.doTag(InsertAttributeTag.java:299)
org.apache.jsp.index_jsp._jspx_meth_tiles_005finsertAttribute_005f1(index_jsp.java:132)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)


提前致谢

最佳答案

您可能有一个拼写错误,文件夹的路径以 value="WEBINF"开头:

   <put-attribute name="header" 
      value="/WEBINF/jsp/modules/tiles/t_header.jsp" >
   </put-attribute>

对比

   <put-attribute name="header" 
      value="/WEB-INF/jsp/modules/tiles/t_header.jsp" >
   </put-attribute>

关于java - Spring 3 MVC + 磁贴 3 : Attribute "header" not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18857105/

相关文章:

java - Selenium 新的等待条件不起作用被迫使用 Thread.Sleep

java - 如何使 Spring 将值注入(inject)静态字段

java - 如何使用Spring Boot连接h2数据库?

spring - 如何使用 Spring Mongo 对两个字段进行分组并根据另一个字段获取一个字段的数组?

jsp - 如何在jsp中获取 Controller 名称?

java - 3-Sum Java 到 Python 的转换

java - 使用 PDFBox 提取便笺

Java Webstart 安全性

javascript - 如何使用 javascript 将参数从 JSP 传递到 Servlet

java - 读取一个文本文件并写入多个文本文件以进行过滤/提取