JSF中的HTML文档类型声明 [英] HTML doctype declaration in JSF
问题描述
我在JSF页面中有一个非常奇怪的问题,无法解决.我在xhtml页面中有以下html doctype声明:
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>
当我运行JSF页面并打开Furebug到页面代码时,我得到了这一点:
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>
应该是这样的:
<!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>
我不知道为什么跳过html doctype?您能帮我解决这个问题吗?
I don't know why the html doctype is skipped? Can you help me to fix this?
P.S我使用JSF导航导航到新页面:
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>
我不知道为什么在打开新的JSF页面时不包含HTML doctype声明.
I don't know why when the new JSF page is opened the HTML doctype declaration is not included.
推荐答案
最近的Mojarra版本存在一个错误,该错误会导致在呈现的HTML中删除该文档类型.如果包含的文件自己定义了doctype,则似乎会发生这种情况.如果使用受影响的版本(< 2.1.14),则可能要检查
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
如果在包含文件中定义了文档类型,则文档类型不会在生成的HTML中呈现
这篇关于JSF中的HTML文档类型声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!