Apachetiles将没有内容的打开标签和关闭标签转换为空标签
Apachetiles将没有内容的开始标签和结束标签转换为空标签。
例如 将写为
,这破坏了我的 HTML。
如何防止这种行为?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
下面的解决方案有效。这就是 Spring Roo 解决了这个问题。
Solution below works. This is how Spring Roo work-around this problem.
您需要在脚本开始和结束标记之间放置一些内容,足以阻止 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?
它真的“破坏了你的 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
orapplication/xhtml+xml
? It seems some browser will not be too happy with XHTML delivered as text/html.我想这行不通吧?
或者
不太确定上述方法是否能解决验证问题,即使它确实有效
I don't suppose this works?
or
Not too sure the above would even solve the validation issue, even if it did work