Apachetiles将没有内容的打开标签和关闭标签转换为空标签

发布于 2024-08-06 08:29:56 字数 184 浏览 9 评论 0原文

Apachetiles将没有内容的开始标签和结束标签转换为空标签。

例如 将写为

如何防止这种行为?

Apache tiles converts open tag and close tag with no content to an empty tag.

For example <script src="some.js"></script> will be written as <script src="some.js"/>, which breaks my HTML.

How to prevent this behaviour?

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

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

发布评论

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

评论(4

染墨丶若流云 2024-08-13 08:29:56

下面的解决方案有效。这就是 Spring Roo 解决了这个问题。

<script src="some.js"><!----></script>

Solution below works. This is how Spring Roo work-around this problem.

<script src="some.js"><!----></script>
独享拥抱 2024-08-13 08:29:56

您需要在脚本开始和结束标记之间放置一些内容,足以阻止 Tiles 将其折叠。尝试一些空格、换行符,甚至是  。如果 Tiles 继续这样做,你需要在其中引入一些不会崩溃的内容,也许是 javascript 注释?

You need to put some content in between the script start and end tags, enough to stop Tiles from collapsing it down. Try some white space, or a line break, or even a  . If Tiles keeps doing it, you need to introduce some content in there that it won't collapse, perhaps a javascript comment?

绻影浮沉 2024-08-13 08:29:56

它真的“破坏了你的 HTML”吗?您是否检查过验证器,例如 validator.w3.org?您正在描述完全有效的 XML。您的 HTML 应遵循哪个 DTD?就我个人而言,我的目标是 XHTML,这不是问题。

编辑:您的服务器提供的是text/html还是application/xhtml+xml?似乎某些浏览器对以 text/html 形式提供的 XHTML 不太满意。

Does it really "break your HTML"? Did you check with a validator, like validator.w3.org? You are describing perfectly valid XML. To which DTD should your HTML conform? Personally, I would aim for XHTML, where this is not a problem.

Edit: Is your server delivering text/html or application/xhtml+xml? It seems some browser will not be too happy with XHTML delivered as text/html.

不一样的天空 2024-08-13 08:29:56

我想这行不通吧?

<script src="some.js" type="text/javascript"></script>

或者

<script src="some.js" type="text/javascript"> </script>

不太确定上述方法是否能解决验证问题,即使它确实有效

I don't suppose this works?

<script src="some.js" type="text/javascript"></script>

or

<script src="some.js" type="text/javascript"> </script>

Not too sure the above would even solve the validation issue, even if it did work

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