java - eclipse :Dynamic Web Application shows blank page when run on server

标签 java jsf xhtml

我专门遵循本指南:http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jst.jsf.doc.user%2Fhtml%2Fgettingstarted%2Ftutorial%2FJSFTools_tutorial_JSF20.html

在服务器上运行 xthml 文件时,我收到一个空白页面,但我不完全确定原因。

希望有一个简单的解决方案。如果需要,我可以提供更多信息。谢谢!

这是我尝试在服务器(apache tomcat6)上运行的 xhtml 文件

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<ui:composition>
    <ui:define name="content">
        <h:form>
            <h:panelGrid columns="2">
                <h:outputText value="Name"></h:outputText>
                <h:inputText value="#{loginBean.name}"></h:inputText>
                <h:outputText value="Password"></h:outputText>
                <h:inputSecret value="#{loginBean.password}"></h:inputSecret>
            </h:panelGrid>
            <h:commandButton value="Login" action="login"></h:commandButton>
        </h:form>
    </ui:define>
</ui:composition>
</html>

这是 web.xml

<?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_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Xperiment</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <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>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
</web-app>

最佳答案

<ui:define> 应该用于在模板文件中为其他 View 定义部分,因此其他 View 将使用 <ui:insert>定义每个特定 View 的组件。由于您的 View 将用作要遵循的模板文件,因此没有 content要显示的部分,因此 JSF 将不显示任何内容(空白页)。

正在删除<ui:define>标签应该使您的 View 按预期工作。

更多信息:

关于java - eclipse :Dynamic Web Application shows blank page when run on server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23728388/

上一篇:java - Sprite 和图层

下一篇:Java AWT 边界

相关文章:

jsf - 使用 Primefaces 将复选框设置为只读

css - 配置 Eclipse 以解析在 facelets 模板中声明的 css 类

javascript - jQuery 正则表达式帮助

jsf - Primefaces BlockUI 不工作

html - 将 svg 转换为 html+css

css - 使用 css 的渐变顶部边框

java - Gradle 构建 - 非 Java 项目

java - 查找和存储组合

java - 如何从 Java 项目运行 Docker 容器?

java - 如何在 mac os mavericks 上安装 Netbeans 7.4(已经安装了 jdk 7 update 45)?