gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 14:06:31 25 4
gpt4 key购买 nike

我正在尝试使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com