【发布时间】:2012-09-10 19:28:10
【问题描述】:
我在 JSF 页面中有一个非常奇怪的问题,我无法解决。我在 xhtml 页面中有这个 html doctype 声明:
<?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 到页面代码时,我得到这个:
<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 被跳过了?你能帮我解决这个问题吗?
P.S 我使用 JSF 导航导航到新页面:
<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声明。
【问题讨论】:
-
它被称为“HTML doctype 声明”,而不是“HTML 标准声明”。