0

我正在尝试使用springand构建一个小型 Web 应用程序3mvc tiles3。当我启动应用程序时,我收到这样的错误:

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

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

瓷砖.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)


提前致谢

4

1 回答 1

1

It looks like you may have a typo, the path for folder starts with 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>
于 2013-09-18T04:00:39.657 回答