Spring3 MVC + tiles3:找不到属性“header”

时间:2013-09-17 18:20:45

标签: java spring jsp spring-mvc apache-tiles

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

org.apache.tiles.template.NoSuchAttributeException: Attribute 'header' not found.

我读了一些先前的线程,这可能是.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)


提前谢谢

1 个答案:

答案 0 :(得分:1)

看起来你可能有一个拼写错误,文件夹的路径以value =“WEBINF”开头:

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

VS

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