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

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

问题描述

我正在尝试在其他计算机上的 Apache Tomcat 上运行我的 Eclipse JSF 项目.我使用 本教程创建了一个 WAR 文件.但是,当我部署 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 文件似乎没有任何相关的样式信息.文档树如下所示.

当客户端(Web 浏览器)出于某种原因将表示 HTML 文档的 HTTP 响应内容解释为 text/xml 而不是 text/时,您将在客户端收到此消息html 并且解析的 XML 树没有任何 XML-stylesheet.换句话说,由于缺少或不正确的 HTTP 响应内容类型,Web 浏览器将检索到的 HTTP 响应内容解析为 XML 而不是 HTML.

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

如果 JSF/Facelets 文件具有 .xhtml 的默认扩展名,如果 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 与在webapp 的 web.xml,以便它被调用并能够基于 XHTML 源代码生成所需的 HTML 输出.如果是例如*.jsf,那么您需要通过/some.jsf 而不是/some.xhtml 打开页面.或者,您也可以将 更改为 *.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.

因此请注意,您实际上并不需要 XML 样式表.在您的特定情况下,这只是网络浏览器的一种误解,同时试图尽最大努力从检索到的 HTTP 响应内容中做出一些可呈现的内容.

Note thus that you don't actually need a XML stylesheet. In your specific case it was just a misinterpretation from the webbrowser while trying to do its best to make something presentable out of the retrieved HTTP response content.

这篇关于打开 JSF Facelets 页面显示“此 XML 文件似乎没有任何与之关联的样式信息".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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