Tiles.xml
<tiles-definitions>
<definition name="template" template="/WEB-INF/jsp/template.jsp">
<put-attribute name="title" value="Lets see"/>
<put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
<put-attribute name="body" value="/WEB-INF/jsp/ads.jsp "/>
<put-attribute name="center" value="/WEB-INF/jsp/ads.jsp" />
<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
</definition>
</tiles-definition>
这就是我的template.jsp的外观
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ 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=UTF-8">
</head>
<body>
<table border="0" cellpadding="2" cellspacing="2" align="center">
<tr>
<td height="30" colspan="2"><tiles:insertAttribute name="header" />
</td>
</tr>
<tr>
<td width="350"><tiles:insertAttribute name="body" /></td>
</tr>
<tr>
<td height="30" colspan="2"><tiles:insertAttribute name="footer" />
</td>
</tr>
</table>
</body>
</html>
1) 中心属性和身体属性之间的区别是什么?2) 我们可以给这些属性任意命名吗?3) 除了这里提到的属性之外,还有什么其他属性?
请提供一些与示例图像不同的显示。
What is the difference between center and body attribute?
根据您的配置,中心和身体之间没有区别。
What are the other attributes other than the ones mentioned here?
在tile中,您可以定义自己的属性,这些属性将充当html标记的占位符。您的主模板将是/WEB-INF/jsp/template.jsp
,它将具有属性,您可以根据要生成的视图用自定义html标记替换这些属性。
有关详细信息,请阅读本文档。
似乎有相同视图的重复。如果移除属性名称为center的标记并保留属性名称为body的标记,应该没问题。然而,如果你有这样的要求,这取决于你保留两者。是的,可以给出任意的名称,但如果你给出页眉、页脚、正文、左、右等名称,这是有意义的。