JSF 标签未呈现为 HTML [英] JSF tags not being rendered as HTML

查看:22
本文介绍了JSF 标签未呈现为 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习使用 NetbeansGlassfishJava EE firstcup 教程.

I'm following the Java EE firstcup tutorial using Netbeans and Glassfish.

当我执行 JSF web 层时,我被指示进行编码,浏览器会获得在 .xhtml 文件中编码的相同 JSF 标记,并且标记不会呈现为 HTML 标记.我通过在浏览器中使用查看源代码来了解这一点.

When I execute the JSF web tier I've been instructed to code, the browser gets the same JSF markup coded in the .xhtml file, and the tags are not rendered as HTML tags. I know this by using the view source code in my browser.

例如,对于此代码:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Page title here</title>
    </h:head>
    <h:body>
        <h2>
            <h:outputText value="#{bundle.WelcomeMessage}" />
        </h2>
    </h:body>
</html>

浏览器应该是这样的:

<html ...>
    <head>
        <title>Page title here</title>
    </head>
    <body>
        <h2>
            the welcome message goes here
        </h2>
    </body>
</html>

对吗?

好吧,我的浏览器正在获取 jsf 代码(上面的第一段代码)而不是 html 代码(上面的第二段代码).

Well, my browser is getting jsf code (the first piece of code above) and not the html code (the second piece of code above).

这似乎是 netbeans 或 glassfish 中的配置问题,但不知道是什么.有什么想法吗?

It seems to be a configuration problem in netbeans or glassfish but don't know what. Any ideas?

这是我的 web.xml 文件:

This is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/firstcup/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>greetings.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

这是我的 faces-config.xml 文件:

This is my faces-config.xml file:

<?xml version='1.0' encoding='UTF-8'?>

<!-- =========== FULL CONFIGURATION FILE ================================== -->

<faces-config version="2.0"
              xmlns="http://java.sun.com/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

    <application>
        <resource-bundle>
            <base-name>firstcup.web.WebMessages</base-name>
            <var>bundle</var>
        </resource-bundle>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>es</supported-locale>
        </locale-config>
    </application>
    <navigation-rule>
        <from-view-id>/greetings.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/response.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
</faces-config>

<小时>

此外:

推荐答案

SOLVED:将 web.xml 中的 welcome-file 更改为以下内容解决了问题:

SOLVED: Changing the welcome-file in web.xml to the following solved the problem:

<welcome-file-list>
    <welcome-file>firstcup/greetings.xhtml</welcome-file>
</welcome-file-list>

这篇关于JSF 标签未呈现为 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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