2013-06-01 163 views
0

我只用一个页面index.xhtml(eclipse juno 4.2 + JBoss AS 7.1)制作了基本的动态web项目。当我运行我的网页时,浏览器只显示html元素而不是jsf。我的index.xhtml代码:不显示jsf元素

<?xml version="1.0" encoding="UTF-8" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:h="http://java.sun.com/jsf/html"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title></title> 
</head> 
<body> 
push the button: 
<button>ok</button> 
<h:button value="not ok"></h:button> 
</body> 
</html> 

我只能看到“ok”按钮。 当我开始我的服务器(独立的)我已经警告说:

WARN [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Tomcat6InjectionProvider:org.apache.catalina.util.DefaultAnnotationProcessor' for service type 'com.sun.faces.spi.injectionprovider' 
WARN [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Jetty6InjectionProvider:org.mortbay.jetty.plus.annotation.InjectionCollection' for service type 'com.sun.faces.spi.injectionprovider' 
WARNING [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) JSF1069: Disabling the JSF 2.0 Facelets ViewHandler as an older FaceletViewHandler, com.sun.facelets.FaceletViewHandler, has been explicitly configured. If this is not desired behavior, remove the older FaceletViewHandler and library from your application. 

假如任何人同样的问题?我犯了错误,或者IDE或服务器有一些错误? 感谢您的帮助。

我有另一个问题。我想添加库主面。我右键单击项目然后属性 - >部署程序集 - >添加和.jar显示在管理窗口中,但库不出现在文件层次结构(WEB-INF/lib)中。

回答

3

你的webapp的运行时类路径是一团糟。在日志的最后警告已经是全部答案:

JSF1069:禁用JSF 2.0的Facelets的ViewHandler作为一个大FaceletViewHandler,com.sun.facelets.FaceletViewHandler,已明确配置。如果这不是所期望的行为,请从应用程序中删除旧的FaceletViewHandler和库。

你这本身已经因某种原因从Facelets的1.x的一个jsf-facelets.jar文件在你的web应用的运行时类路径(如com.sun.facelets包装标识),当你使用JSF 2.0已经打包的Facelets 2.X(如com.sun.faces.facelets包所示)。

摆脱jsf-facelets.jar以及您的webapp的运行时类路径中的其他JSF 1.x相关构件(以及/WEB-INF/lib文件夹覆盖的其他文件)。停止阅读JSF 1.x有针对性的书籍/教程/资源,并前往JSF 2.x版本。在JSF 2.x中,许多事情都做了不同的处理,所以依赖JSF 1.x资源只会陷入混乱和麻烦之中。

在已经捆绑了JSF 2.x的JBoss 7上,在/WEB-INF/lib中不需要任何JAR。你也不需要把任何东西放在faces-config.xml。如果您使用的是JSF 2.1并依赖*.jsf的默认URL映射,那么您也不需要将任何东西放入web.xml。所以这两个文件可以有效地保持空白。