【发布时间】:2013-09-29 05:24:32
【问题描述】:
我是 Java 和 JSF 的新手。我正在使用 eclipse Indigo 和 Tomcat 6.0.3 和 JSF 2.0。
当我在浏览器中运行页面时,我只是得到一个空页面,但我可以在 firebug 中看到它仍然在 JSF 标记本身中的元素。它没有在 html 中呈现..
这是我的 web.xml
<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>/app/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>pages/AddUser.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<session-config>
<session-timeout>15</session-timeout>
</session-config>
我已尝试将url-pattern 添加为*.xhtml,但它仍然不起作用。
这是我的 xhtml 文件..
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Add New User Form</title>
</h:head>
<h:body>
<f:view>
<h:form>
<h:outputText value="Age"></h:outputText>
</h:form>
</f.view>
</h:body>
【问题讨论】:
-
你能提供xhtml文件的代码吗?并且除了这个问题之外已经存在。检查这个。 stackoverflow.com/questions/2207616/… 或 stackoverflow.com/questions/8764204/… 也许还有这个。 stackoverflow.com/questions/4866597/jsf-not-being-rendered
-
我已经尝试了这些页面上提到的大部分内容,但效果不佳,所以我为此创建了一个新页面......
-
你在浏览器中写的完整url是什么?
-
您访问页面的 URL 格式是什么?
-
localhost:8080/ContactFormJSF 有一些 html 元素,单独可以看到,但没有 jsf 元素...