我开始学习JavaServer Faces(JSF) 。 我使用GlassFish 3+。 我刚刚在Netbeans创建了一个新的JSF项目并运行了这个项目。 它运作良好, 但在检查 XHTML 输出后, 我注意到XML 声明被留在了其中。 这破坏了 DOCTYPE 声明( 在文件中总是应该居首位 ) 。
""https://i.sstatic.net/ly5VA.jpg" alt="此处输入图像描述"/"
JSF是应该删除 XML 声明, 还是我做错了什么?
我开始学习JavaServer Faces(JSF) 。 我使用GlassFish 3+。 我刚刚在Netbeans创建了一个新的JSF项目并运行了这个项目。 它运作良好, 但在检查 XHTML 输出后, 我注意到XML 声明被留在了其中。 这破坏了 DOCTYPE 声明( 在文件中总是应该居首位 ) 。
""https://i.sstatic.net/ly5VA.jpg" alt="此处输入图像描述"/"
JSF是应该删除 XML 声明, 还是我做错了什么?
默认情况下, 脸板只会从组成( 包括文件和复合组件) 和标签文件中删除它。 它不会从主控模板中删除它。 您自己去掉它。 您在撰写 HTML 时不应该使用 XML 程序 。
从主模板中删除 XML Prolog 是否在 < a href=> 的附录1.1.1.1 中指定 :http://download.oracle.com/otndocs/jcp/jsf-2_2-fr-eval-spec/index.html" rel= "Nofoln noreferr" > JSF2.2 规范 ,该规范描述着 faces-config.xml
元素的配置。 XML prolog被描述为“处理指令”。 在表格中,您可以看到,当模板作为 XML 或 JSPX 视图处理时,它才被删除( 包印) 。
1.1.1.1 The
facelets-processing
elementThe
<facelets-processing>
element is used to affect the processing of Facelets VDL files. Therefore, this setting only applies to those requests that reach the FaceletsViewDeclarationLanguage
implementation, as specified to the runtime via thejavax.faces.FACELETS_VIEW_MAPPINGS
andjavax.faces.DEFAULT_SUFFIX
<context-param>
entries. The specification defines three processing modes for Facelets files: Facelets XHTML syntax, XML View syntax, and Facelets JSPX syntax. This last syntax is intended to ease the migration to Facelets for applications already using the JSP document syntax (also known as JSPX syntax). The affect on the processing of files in each of these three modes is specified in the following table.Valid <process-as> values and their implications on the processing of Facelets. ----------------------------------------------------------------------------------------- <process-as> <process-as> <process-as> <process-as> html5</process-as> xhtml</process-as> xml</process-as> jspx</process-as> HTML 5 (default) Facelets XHTML XML View Facelets JSPX ----------------------------------------------------------------------------------------- XML Doctype Simplified to passed through consumed consumed <!DOCTYPE html> XML passed through passed through consumed consumed declaration Processing passed through passed through consumed consumed instructions CDATA passed through passed through consumed consumed section Escaping of escaped escaped escaped not escaped inline text XML passed through passed through consumed consumed Comments
In the preceding table, “passed through” means that the content is passed through unmodified to the user agent. “consumed” means the content is silently consumed on the server. Note that for CDATA sections, the content of the CDATA section itself is passed through, even if the start and end tags should be consumed. “escaped” means that sensivite content in the response is automatically escaped:
&
becomes&
, for example. “not escaped” means that such content is not escaped.
换句话说,当您正在撰写 HTML 5/ XHTML 时, 您必须自己去掉它。 一个更好的措辞是 : 您不应该在 HTML 5 和 XHTML 页面中包含 XML Prolog, 因为这不需要; 它只在 XML 和 JSPX 页面中需要( 因此Facelets 将自动删除) strong > 。
unit > to the 具体问题, 您应该使用
<h:outputStylesheet name="css/default.css" />
<h:outputStylesheet name="css/cssLayout.css" />
为了让 XML 声明不出现在我完成的页面上, 我发现我可以配置 JSF 将我的. xhtml 文件作为 XML 处理。 在以 XML 模式处理时, xml 声明不会从我的源文件传递到输出。 我还没有注意到进行这一修改的其他副作用 。 (但如果我找到任何副作用, 我会在此跟进 )
为了改变配置,我在脸部配置中添加了以下内容:
<faces-config-extension>
<facelets-processing>
<file-extension>.xhtml</file-extension>
<process-as>xml</process-as>
</facelets-processing>
</faces-config-extension>
希望这有帮助
I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?
I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...
I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...
I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...
Is it a vulnerable using CDATA element in XML documents? If so what happens if we use CDATA element in XML documents?
I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...
I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...
I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml