HTML doctype declaration in JSF

Deadly 提交于 2019-12-11 18:53:44

问题


I have a very strange problem in JSF page that I cannot solve. I have this html doctype declaration into the xhtml page:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <ui:insert name="header">           
            <ui:include src="header.xhtml"/>         
        </ui:insert>
    </h:head>
    <h:body>

When I run the JSF page and I open Furebug to the page code I get this:

<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<body>
</html>

It should be like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<body>
</html>

I don't know why the html doctype is skipped? Can you help me to fix this?

P.S I use JSF navigation to navigate to the new page:

    <h:commandButton id="newdatacenter" styleClass="lbimage" value="New Datacenter" action="#{DatacentersController.navigateToNewDatacenter()}">
     //   <f:ajax render="@form"></f:ajax>
    </h:commandButton>

 // Navigate to New Datacenter page
    public int navigateToNewDatacenter(){
        return 11432;
    }

    <navigation-rule>
        <description>Navigation rule to New Datacenter page</description>
        <from-view-id>/DatacentersList.xhtml</from-view-id>
        <navigation-case>
            <from-action>#{DatacentersController.navigateToNewDatacenter()}</from-action>
            <from-outcome>11432</from-outcome>
            <to-view-id>/NewDatacenter.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>

I don't know why when the new JSF page is opened the HTML doctype declaration is not included.


回答1:


Recent Mojarra versions have a bug which causes the doctype to be removed in the rendered HTML. This seems to occur if included files define a doctype on their own. If you use an affected version (<2.1.14), you might want to check

Doctype not rendered in the generated HTML if doctype was defined in an included file



来源:https://stackoverflow.com/questions/12358196/html-doctype-declaration-in-jsf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!