HTML 包含文件

发布于 2024-08-01 15:40:52 字数 246 浏览 3 评论 0原文

我有一个基本的 Web 应用程序,打包为部署在 GlassFish 上的 EAR。 Web 模块有一些 html 文件。 html 文件有一个通用的页脚,即一个 html 文件,我想将其提取出来并进行包含。 当我这样做并将:

<!--#include virtual="insertthisfile.html" -->

放在 html 文件中时,它不起作用。 这应该有效吗?

I have a basic web application packaged as an EAR deployed on GlassFish.
The web module has some html files.
The html files have a common footer, an html file, that I would like to extract out and make an include.
When I do, and put:

<!--#include virtual="insertthisfile.html" -->

in an html file, it does not work.
Should this work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小兔几 2024-08-08 15:40:52

这是一种称为服务器端包含 (SSI) 的技术。 您的网络主机上可能未启用它。 如果是,有时它们会强制包含的文件需要 .shtml 扩展名,因此请尝试重命名您的文件 insertthisfile.shtml

如果这不起作用,您也许可以在 .htaccess 文件中启用 SSI(假设您的 Web 服务器是 Apache)。 您可以通过谷歌搜索找到有关如何执行此操作的说明。 这里有一个不错的设置

如果失败,我会联系您的网络主机并查看他们是否启用了 SSI。

This is a technique called Server-Side Includes (SSI). It may not be enabled on your web host. If it is, sometimes they force a .shtml extension to be required for included files, so try renaming your file insertthisfile.shtml.

If that doesn't work, you might be able to enable SSIs in a .htaccess file (assuming your web server is Apache). You can find instructions on how to do this by googling. There's a decent set here.

If that fails, I would contact your web host and see if they have SSIs enabled.

〆凄凉。 2024-08-08 15:40:52

这应该有效吗?
也许,在某些特殊设置下,对于一些经验丰富的程序员来说,这可能很有用。
就我而言,包含语句似乎被忽略。

我可以在上面包含一些文本

(embed src="include.shtml")
(/embed)

,我输入 () 而不是尖括号。

使用“嵌入”时,页面标题中的设置不适用于包含的文本; 它应该再次重复,并且默认情况下,结果很难看。
看起来很奇怪,好像 html 的设计者没有内置非常基本的工具,即 include 命令。 对于短文章,包含可以节省一个数量级的文件大小。

Should this work?
Perhaps, at some special settings, with some experienced programmer, this could be useful.
In my case the include statement seems to be ignored.

I could include some text with

(embed src="include.shtml")
(/embed)

Above, I type () instead of angular brackets.

With the "embed", the setting in the header of the page does not apply to the included text; it should be repeated again, and, by default, the result is ugly.
It looks strange, as if the designers of the html did not build-in the very basic tool, the include command. For short articles, the include could save an order of magnitude in the size of files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文