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

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

问题描述

我使用 Netbeans Glassfish 来关注 Java EE firstcup 教程。

当我执行JSF Web层时,我已经被指示编码,浏览器获得用.xhtml文件编码的相同JSF标记,并且标记不会呈现为HTML标记。我知道这是通过在浏览器中使用查看源代码



例如,对于此代码:

 < 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:头>
< title>页面标题在这里< / title>
< / h:头>
< h:body>
< h2>
< h:outputText value =#{bundle.WelcomeMessage}/>
< / h2>
< / h:body>
< / html>

浏览器应该显示如下内容:

 < html ...> 
< head>
< title>页面标题在这里< /标题>
< / head>
< body>
< h2>
欢迎讯息传到这里​​
< / h2>
< / body>
< / html>

对吗?

正在获取jsf代码(上面的第一段代码)而不是html代码(上面的第二段代码)。

这似乎是NetBeans中的配置问题或玻璃鱼,但不知道什么。任何想法?






这是我的web.xml文件:

 <?xml version =1.0encoding =UTF-8?> 
< web-app version =3.0xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/ XMLSchema-instancexsi: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>
<参数值>开发< /参数值>
< / context-param>
< servlet>
< servlet-name> Faces Servlet< / servlet-name>
< servlet-class> javax.faces.webapp.FacesServlet< / servlet-class>
<加载启动> 1< /加载启动>
< / 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文件:

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

<! - - ===========完整配置文件======================= =========== - >

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的/网络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>
<从结果>成功< /从结果>
< to-view-id> /response.xhtml< / to-view-id>
< / navigation-case>
< / navigation-rule>
< / faces-config>






此外:

解决方案

:将 web.xml 中的欢迎文件更改为以下解决方案: 问题:

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


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

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.

For example, for this code:

<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>

The browser should get something like:

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

Right?

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

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


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>

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>


Moreover:

解决方案

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天全站免登陆