2014-11-21 39 views
0

我刚刚下载了Tomcat 7.0.53,并用Mojarra 2.0.3实现编写了我的第一个JSF2.0 Hello World XHTML文件(helloworld.xhtml)。

我的web.xml文件是:我的第一个JSF xhtml正在显示空白页

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 
    <display-name>webroot</display-name> 
    <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>*.faces</url-pattern> 
    </servlet-mapping> 

</web-app> 

我faces-config.xml中是:

<?xml version="1.0" encoding="UTF-8"?> 
<faces-config 
    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" 
    version="2.0"> 

</faces-config> 

我的WebContent/WEB-INF/lib文件夹包含以下jar文件:

jsf-api.jar 
jsf-impl.jar 
jstl.jar 
standard.jar 
我的helloworld.xhtml的代码是:

当我运行这个使用

http://localhost:8080/webroot/helloworld.faces 

它显示了一个空白页。出了什么问题?

+0

是否至少有一个标题? – 2014-11-21 20:53:38

+0

通常情况下,您可以在web.xml中映射* .xhtml并调用localhost:8080 /.../ helloworld.xhtml。 “* .faces”来自JSF1天 – 2014-11-21 21:30:37

回答

0

您使用的outputText是错误的

将其更改为

<h:outputText value="Hello World"></h:outputText> 
+0

谢谢Salih Erikci!它的工作现在。 – samskir 2014-11-25 17:16:50