HTML 包含文件
我有一个基本的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一种称为服务器端包含 (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 fileinsertthisfile.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.
我可以在上面包含一些文本
,我输入
()
而不是尖括号。使用“嵌入”时,页面标题中的设置不适用于包含的文本; 它应该再次重复,并且默认情况下,结果很难看。
看起来很奇怪,好像 html 的设计者没有内置非常基本的工具,即 include 命令。 对于短文章,包含可以节省一个数量级的文件大小。
I could include some text with
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.