打开XML页面显示“此XML文件似乎没有与之关联的任何样式信息”。 [英] Opening XML page shows "This XML file does not appear to have any style information associated with it."

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

问题描述

我正在尝试在另一台计算机上的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文件似乎没有与之关联的任何样式信息。文档树如下所示。

当客户端(网络浏览器)在客户端出现此错误由于某些原因,将HTTP响应内容解释为 text / xml 而不是 text / html ,并且已解析的XML树不会没有任何 XML样式表。换句话说,由于HTTP响应内容类型错误或丢失,Web浏览器将检索到的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 /具有默认扩展名 .xhtml 的Facelets文件,如果HTTP请求未调用 FacesServlet ,因此它无法解析Facelets文件并基于XHTML源代码生成所需的HTML输出。 Firefox然后只是猜测基于 .xhtml 文件扩展名的HTTP响应内容类型,该文件扩展名显然在Firefox配置中默认解释为 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与相匹配。在Web应用程序的 web.xml 中注册的 FacesServlet 的< url-pattern> ,因此它将被调用并能够基于XHTML源代码生成所需的HTML输出。例如,如果使用 *。jsf ,则需要通过 /some.jsf 而不是 /some.xhtml 。另外,您也可以将< url-pattern> 更改为 *。xhtml 。这样,您就无需摆弄虚拟URL。

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.

  • 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页面显示“此XML文件似乎没有与之关联的任何样式信息”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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