3

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?

4 Answers4

2

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

<script src="some.js"><!----></script>
Eugene Ramirez
  • 3,053
  • 2
  • 23
  • 17
0

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.

Volker Stolz
  • 7,274
  • 1
  • 32
  • 50
  • This is not a validation issue. Page displays incorrect in my browser, because some HTML tags required to be ended, such as textarea or script. –  Oct 02 '09 at 13:11
  • Try this HTML code with not ended script tag. The body wouldn't be displayed. Forum Some content –  Oct 02 '09 at 13:17
0

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 &nbsp;. If Tiles keeps doing it, you need to introduce some content in there that it won't collapse, perhaps a javascript comment?

skaffman
  • 398,947
  • 96
  • 818
  • 769
  • Comment doesn't work, but   or some content works. But what about textarea tag, if I don't whant any content in it? –  Oct 02 '09 at 13:32
-1

I don't suppose this works?

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

or

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

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

wiifm
  • 3,787
  • 1
  • 21
  • 23