tile定义中的center和body属性有什么区别?

时间:2014-09-22 02:45:46

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

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)除了这里提到的那些之外还有哪些其他属性?

请提供示例图像的一些差异。

2 个答案:

答案 0 :(得分:2)

What is the difference between center and body attribute? 

根据您的配置,中心和身体之间没有区别。

What are the other attributes other than the ones mentioned here?

在图块中,您可以定义自己的属性,这些属性将充当html标记的占位符。您的主模板将是/WEB-INF/jsp/template.jsp,其中的属性可以根据您要生成的视图替换为自定义html标记。

阅读this文档以获取更多信息。

答案 1 :(得分:0)

似乎有相同视图的重复。如果删除属性name = center的标记并保留标记属性name = body,则应该没问题。 但是,如果你有这样的要求,你可以保留两者。 是的,它可以提供任意名称,但如果你给出页眉,页脚,正文,左,右等名称是有道理的。