Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
标签来自http://xmlns.jcp.org 命名空间不呈现,而http://java.sun.com/jsf 干得好_Jsf_Facelets_Xml Namespaces - Fatal编程技术网

标签来自http://xmlns.jcp.org 命名空间不呈现,而http://java.sun.com/jsf 干得好

标签来自http://xmlns.jcp.org 命名空间不呈现,而http://java.sun.com/jsf 干得好,jsf,facelets,xml-namespaces,Jsf,Facelets,Xml Namespaces,我有这个: <html xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://java.sun.com/jsf/html" > <h:selectOneRadio> <f:selectItem value="1" itemValue="1" itemLabel="123"/> <f:selectItem value="2" itemValue="2" itemLa

我有这个:

<html 
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
>
<h:selectOneRadio>
    <f:selectItem value="1" itemValue="1" itemLabel="123"/>
    <f:selectItem value="2" itemValue="2" itemLabel="321"/>
</h:selectOneRadio>

我明白了:

<f:selectItem value="1" itemValue="1" itemLabel="123"></f:selectItem>
<f:selectItem value="2" itemValue="2" itemLabel="321"></f:selectItem>
<select name="j_idt5" size="1"></select>

为什么
xmlns:f=”http://xmlns.jcp.org/jsf/core“
标记是否未呈现


我在Netbeans 7.3上使用JBoss AS 7。

新的XML命名空间域
http://xmlns.jcp.org
在JSF中,taglib URI是在JSF 2.2中引入的,JSF 2.2是JavaEE7的一部分。JBossAS7作为一个兼容JavaEE6的应用服务器,并没有附带JSF2.2,而是附带JSF2.1。因此,新的XML命名空间域根本不起作用。此外,新的JSF2.2特定特性(如passthrough元素和属性)根本不起作用

您需要使用JSF2.1兼容的XML命名空间域
http://java.sun.com
。这是完整的一套:

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

我不知道您为什么尝试使用新的JSF2.2XML名称空间。也许您错误地阅读了JSF2.2目标教程(例如),而不是JSF2.0/2.1目标教程(例如)。请仔细注意版本是否匹配


如果您真的打算在JBoss服务器上使用JSF2.2,那么您基本上应该将旧的JBossAS7升级到与JavaEE7兼容的后续版本。或者,手动将JBoss AS 7的捆绑JSF库升级到更新版本,如下所示:。

请查看WEB-INF文件夹 还有web.xml 如果没有这样的文件,则不会使用jsf 许多jboss的maven原型都没有这个文件 在WEB-INF文件夹中创建此文件 样本:

 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id=“WebApp\u id”version=“2.5”>

JavaServerFaces
javax.faces.PROJECT_阶段
发展
faces/hello.xhtml
Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
/面孔/*
Facesservlet
*.jsf
Facesservlet
*.面孔
Facesservlet
*.xhtml

问题似乎在于您没有使用JSF2.2,因此必须将名称空间定义为
xmlns:f=”http://java.sun.com/jsf/core“
。这很有帮助!非常感谢你!我使用的是NetBeans 7.3,它会自动添加“错误”名称空间。我不知道为什么它强加了新的测试版JSF2.2而不是旧的。你把当前的问题和另一个问题混淆了:基本上,你把这个“答案”贴到了一个错误的问题上。顺便说一下,没有必要有4个松散的servlet映射。您只能有1个URL模式和4个URL模式。即使如此,拥有4个URL模式也是荒谬的,而且不利于SEO。只需坚持使用一个,
*.xhtml
<display-name>JavaServerFaces</display-name>

<!-- Change to "Production" when you are ready to deploy -->
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<!-- Welcome page -->
<welcome-file-list>
    <welcome-file>faces/hello.xhtml</welcome-file>
</welcome-file-list>

<!-- JSF mapping -->
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- Map these files with JSF -->
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>