无法将NetBeans Web项目部署到GlassFish服务器

时间:2019-02-13 06:56:09

标签: jsf java-ee netbeans glassfish java-ee-7

尝试在NetBeans中创建第一个hello world Java Web应用程序并将其部署到在本地主机上运行的GlassFish 5服务器上。当我在NetBeans 10中运行我的应用程序时,它将以http://localhost:8080/intro-to-jsf-nb10/的外观打开页面为错误HTTP Status 404 - Not Found

的网页浏览器

我期望NB将项目文件部署在GlassFish文件夹中的某个位置,但找不到我的index.xhtml

如果我导航到GF5\glassfish\domains\domain1\docroot文件夹,则会看到默认的GlassFish网页index.xtml,但找不到我的那个。

如何解决此问题?

我有一个WelcomePageBean Java类:

package com.samples.linkedin.jsf.page;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;


@Named("welcomePageBean")
@RequestScoped
public class WelcomePageBean {

    private String welcomeUserName;
    private String completedGreeting;

    /**
     * @return the welcomeUserName
     */
    public String getWelcomeUserName() {
        return welcomeUserName;
    }

    /**
     * @param welcomeUserName the welcomeUserName to set
     */
    public void setWelcomeUserName(String welcomeUserName) {
        this.welcomeUserName = welcomeUserName;
    }

    /**
     * @return the completedGreeting
     */
    public String getCompletedGreeting() {
        return completedGreeting;
    }

    /**
     * @param completedGreeting the completedGreeting to set
     */
    public void setCompletedGreeting(String completedGreeting) {
        this.completedGreeting = completedGreeting;
    }



    public void sayHello()
    {
    completedGreeting = "Hello, "+welcomeUserName;
    }
}

index.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://xmlns.jcp.org/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form>
            <h:panelGrid columns="2">
                <h:outputLabel for="inputTextBox" value="Enter a name here" />
                <h:inputText value="#{welcomePageBean.welcomeUserName}" id="inputTextBox"></h:inputText>
                <h:commandButton value ="Say Hello" action="#{welcomePageBean.sayHello}"/>
                <h:outputText value="#{welcomePageBean.completedGreeting}"/>
            </h:panelGrid>
        </h:form>
    </h:body>
</html>

0 个答案:

没有答案