0

我知道这可能是一个愚蠢的问题,但我想了解 opencms 中的 jsp 模板。

即使我们在 jsp 中有 htm 标签。cms 标签的实际用途是什么,例如:

 <cms:template element="body">
<cms:include element="body" />

4

2 回答 2

1

如本维基页面所述,您可以通过 cms 标签 cms:template 在 jsp 文件中定义模板部分,然后通过 cms 标签 cms:include 将它们包含在您的 jsp 页面中

于 2014-05-27T12:27:32.990 回答
0

cms:模板标签

使用标签,您可以将控制结构添加到模板中,使其能够处理多个页面元素。

cms:include 标签

此标记用于在运行时动态包含来自 OpenCms VFS 的文件。包含的文件被视为带有可选附加请求参数的请求。通过使用以下属性之一来确定包含文件的名称有不同的选项: - 页面 - 属性 - 属性

如果没有设置这些属性,则评估标记的主体并将结果用作文件名。

<%@ page session="false" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>

<cms:template element="head">

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><cms:property name="title" escapeHtml="true" /></title>

<meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; CHARSET=<cms:property name="content-encoding" default="ISO-8859-1" />">

<link type="text/css" rel="stylesheet" href="<cms:link>../resources/mystyle.css</cms:link>">

<cms:editable />

</head>
<body>

<h2>My first template head</h2>

<!-- Main page body starts here -->
</cms:template>

<cms:template element="body">

<h2>This is the first page element:</h2>

<cms:include element="body" editable="true"/>

<cms:template ifexists="body2">
<h2>This is the second page element:</h2>
<cms:include element="body2" editable= "true"/>
</cms:template>


</cms:template>

<cms:template element="foot">
<!-- Main page body ends here -->

<h2>My first template foot</h2>

</body>
</html>
</cms:template>
于 2017-03-31T05:45:42.250 回答