使用“此XML文件似乎没有与其相关联的任何样式信息打开Facelets页面错误”。 [英] Opening Facelets page errors with "This XML file does not appear to have any style information associated with it."

查看:153
本文介绍了使用“此XML文件似乎没有与其相关联的任何样式信息打开Facelets页面错误”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在其他计算机上的Apache Tomcat上运行我的Eclipse JSF项目。
我用本教程。但是,当我部署WAR并在Firefox中打开Facelet页面时,我只会收到以下错误消息:

I'm trying to run my Eclipse JSF project on Apache Tomcat on other computer. I created a WAR file with this tutorial. However, when I deploy the WAR and open the Facelet page in Firefox, I'm getting only the following error message:


此XML文件似乎没有与之相关联的任何样式信息。文档树如下所示。

This XML file does not appear to have any style information associated with it. The document tree is shown below.

这是我第一次在没有Eclipse的情况下运行我的JSF应用程序。这是如何造成的,我该如何解决?

This my first time when I try run my JSF app without Eclipse. How is this caused and how can I solve it?

我实际上正在尝试打开以下的Facelet页面:

I'm actually trying to open the following Facelet page:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/WEB-INF/templates/template_a.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:define name="title">
        tytol
    </ui:define>
</ui:composition>


推荐答案


XML文件似乎没有与其相关联的任何样式信息。文档树如下所示。

当客户端(webbrowser)由于某种原因将HTTP响应内容解释为 text / xml 而不是 text / html ,解析的XML树不会没有任何 XML样式表。换句话说,由于错误或缺少的HTTP响应内容类型,webbrowser将错误地将检索到的HTTP响应内容解析为XML而不是HTML。

You will get this error in the client side when the client (the webbrowser) for some reason interprets the HTTP response content as text/xml instead of text/html and the parsed XML tree doesn't have any XML-stylesheet. In other words, the webbrowser incorrectly parsed the retrieved HTTP response content as XML instead of as HTML due to the wrong or missing HTTP response content type.

如果是JSF / Facelets文件的默认扩展名为 .xhtml ,如果HTTP请求没有调用 FacesServlet ,因此无法根据XHTML源代码解析Facelets文件并生成所需的HTML输出。 Firefox只是根据您的Firefox配置中的 .xhtml 文件扩展名猜测HTTP响应内容类型,默认情况下解释为 text / xml

In case of JSF/Facelets files which have the default extension of .xhtml, that can in turn happen if the HTTP request hasn't invoked the FacesServlet and thus it wasn't able to parse the Facelets file and generate the desired HTML output based on the XHTML source code. Firefox is then merely guessing the HTTP response content type based on the .xhtml file extension which is in your Firefox configuration apparently by default interpreted as text/xml.

您需要确保HTTP请求URL(如浏览器地址栏中所示)与在webapp的 web.xml 中注册的 FacesServlet 以便它被调用并能够基于XHTML源代码生成所需的HTML输出。如果它是例如 *。jsf ,那么您需要通过 /some.jsf 而不是 /some.xhtml 。或者,您也可以将< url-pattern> 更改为 *。xhtml

You need to make sure that the HTTP request URL, as you see in browser's address bar, matches the <url-pattern> of the FacesServlet as registered in webapp's web.xml, so that it will be invoked and be able to generate the desired HTML output based on the XHTML source code. If it's for example *.jsf, then you need to open the page by /some.jsf instead of /some.xhtml. Alternatively, you can also just change the <url-pattern> to *.xhtml. This way you never need to fiddle with virtual URLs.


  • href = Facelets:有时我看到URL是.jsf,有时候是.xhtml。为什么?

  • JSF Facelets: Sometimes I see the URL is .jsf and sometimes .xhtml. Why?

请注意,您实际上不需要XML样式表。这一切都是Web浏览器的错误解释,同时试图尽可能地从检索到的HTTP响应内容中呈现出一些可呈现的东西。实际上应该检索出正确生成的HTML输出,Firefox肯定知道如何处理HTML内容。

Note thus that you don't actually need a XML stylesheet. This all was just misinterpretation by the webbrowser while trying to do its best to make something presentable out of the retrieved HTTP response content. It should actually have retrieved the properly generated HTML output, Firefox surely knows precisely how to deal with HTML content.

这篇关于使用“此XML文件似乎没有与其相关联的任何样式信息打开Facelets页面错误”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆