简体   繁体   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

I'm new to tomcat, I'm just trying to make a hello world application to get used to tomcat, but when I start my application and go to http://localhost:8080/helloweb/index.html it gives me a 404 error. 我是tomcat的新手,我只是想制作一个hello world应用程序以习惯于tomcat,但是当我启动我的应用程序并转到http:// localhost:8080 / helloweb / index.html时,它给了我一个404错误。 If I go to http://localhost:8080/ then it takes me to the default webpage for tomcat. 如果我访问http:// localhost:8080 /,那么它将带我到tomcat的默认网页。 Please help, I've been trying to debug this forever but can't seem to find anyone else that is having this problem. 请帮忙,我一直在尝试调试,但是似乎找不到其他遇到此问题的人。

index.html 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 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 context.xml

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

response.jsp 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>

Project Structure 项目结构

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

Okay, I figured it out. 好吧,我知道了。 I had to go into http://localhost:8080/manager/html and manually upload the .war file. 我必须进入http:// localhost:8080 / manager / html并手动上传.war文件。 Please correct me if I'm wrong, but I was unable to find this anywhere in tomcat's documentation. 如果我错了,请纠正我,但是我在tomcat的文档中找不到任何地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的基于Spring的Restful Web服务在部署到独立的tomcat而不是Eclipse的Tomcat时给出404 - My Spring based Restful webservice gives 404 when deploy to standalone tomcat instead of Eclipse's Tomcat Servlet给出404而不是加载适当的页面。 启动Tomcat时控制台显示严重错误 - Servlet gives 404 instead of loading appropriate page. Console says SEVERE error when launching Tomcat Tomcat在尝试登录时给出HTTP状态404 - Tomcat gives HTTP Status 404 when trying to log in 当我调用我的servlet时,Tomcat给出了404 - Tomcat gives 404 when i call my servlet 尝试访问Tomcat上已部署的战争时获取HTTP状态404 - Get HTTP Status 404 when trying to access deployed war on Tomcat 成功部署战争后,tomcat给出404 - tomcat gives 404 after successful war deployment Tomcat-Eclipse-尝试访问我的Web应用程序时出现404错误 - Tomcat - Eclipse - 404 Error when trying to reach my webapp Tomcat显示404 - Tomcat shows 404 response.sendError()显示Tomcat默认错误页面而不是web.xml指定的错误页面 - response.sendError() shows Tomcat default error page instead of web.xml specified error page 在外部 Tomcat 服务器上运行的 Springboot 在除 index.html 之外的所有内容上都会出现错误 404 - Springboot running on external Tomcat server gives error 404 on everything but index.html
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM