簡體   English   中英

Tomcat正在運行,但是在嘗試訪問我的HTML時給出了404,但安裝后卻顯示了Tomcat的默認頁面

[英]Tomcat running but gives 404 when trying to access my html, but instead shows tomcat's default page after installation

我是tomcat的新手,我只是想制作一個hello world應用程序以習慣於tomcat,但是當我啟動我的應用程序並轉到http:// localhost:8080 / helloweb / index.html時,它給了我一個404錯誤。 如果我訪問http:// localhost:8080 /,那么它將帶我到tomcat的默認網頁。 請幫忙,我一直在嘗試調試,但是似乎找不到其他遇到此問題的人。

index.html

<!DOCTYPE html>
<html>
    <head>
        <title>Index Page</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <h1>Entry Form</h1>

        <form name="Name Input Form" action="response.jsp">
            Enter your name:
            <input type="text" name="Name" value="" />
            <input type="submit" value="OK" />
        </form>
    </body>
</html>

NameHandler.java

package org.mypackage.hello;

public class NameHandler {
    private String name;

    public NameHandler() { 
        name = null;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

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

context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/helloweb"/>

response.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <jsp:useBean id="mybean" scope="session" class="org.mypackage.hello.NameHandler" />
        <jsp:setProperty name="mybean" property="name" />
        <h1>Hello, <jsp:getProperty name="mybean" property="name" />!</h1>
    </body>
</html>

項目結構

My_Project_Root
 |-- pom.xml
 |-- nb-configuration.xml
 `-- src
     `-- main
         |-- java
         |   `-- com
         |       `-- example
         |           `-- my_project
         |               `-- sample_class.java
         |-- resources
         `-- webapp
             |-- META-INF
                 `-- context.xml
             |-- WEB-INF
             |-- index.html

好吧,我知道了。 我必須進入http:// localhost:8080 / manager / html並手動上傳.war文件。 如果我錯了,請糾正我,但是我在tomcat的文檔中找不到任何地方。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM