簡體   English   中英

Spring3 MVC + Tiles3:找不到屬性“標題”

[英]Spring3 MVC + tiles3: Attribute “header” not found

我正在嘗試使用spring3mvc tiles3構建一個小型Web應用程序。 當我啟動應用程序時,出現如下錯誤:

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

我在以前的某個線程上讀到,這可能是.jsp的XML路徑問題,但在我看來,一切都很好。 您能幫我解決這個問題嗎?

tile.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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM