繁体   English   中英

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

[英]What is the difference between center and body attribute in tiles definition?

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?

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

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

似乎有相同的视图重复,如果您删除属性名称= center的标记并保留属性名称= body的标记应该没问题。 但是,如果您有这样的要求,则由您自己决定保留两者。 是的,可以给出任意名称,但是如果您提供诸如header,footer,body,left,right之类的名称,则是有意义的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM