JSF template: rendered page missing DOCTYPE

前端 未结 2 1394
逝去的感伤
逝去的感伤 2021-01-06 19:03

TL;DR: I can\'t get the DOCTYPE header to appear on my JSF pages.

I just inherited a JSF 1.2 project that\'s having some display issues under IE. I\

相关标签:
2条回答
  • 2021-01-06 19:27

    Remove <ui:composition> from your master template, which is the headertemplate.xhtml. It doesn't belong there. The <ui:composition> will strip all other content outside the tag.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        </head>
        <body>
            <ui:insert name="body" />
        </body>
    </html>
    

    Note that the doctype (and xml) declaration is unnecessary in template definition files (the ones using <ui:composition>). Just remove them.

    See also:

    • How to include another XHTML in XHTML using JSF 2.0 Facelets?
    • Facelets 1.x docbook
    0 讨论(0)
  • 2021-01-06 19:31

    You must remember one thing, that everything outside ui:compostion tags is simply cut out, so the DOCTYPE declaration in your case is simply ignored.

    0 讨论(0)
提交回复
热议问题