java - Tomcat正在运行但在尝试访问我的html时给出404,但安装后显示tomcat的默认页面
问题描述
我是 tomcat 的新手,我只是想制作一个 hello world 应用程序来习惯 tomcat,但是当我启动我的应用程序并转到http://localhost:8080/helloweb/index.html它给了我一个404 错误。如果我去http://localhost:8080/那么它会把我带到 tomcat 的默认网页。请帮忙,我一直在尝试永远调试它,但似乎找不到其他有这个问题的人。
索引.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>
名称处理程序.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;
}
}
上下文.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/helloweb"/>
响应.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 文档的任何地方找到它。
推荐阅读
- java - 编译 Android 项目时出现问题
- c# - 基于时间的进程杀死 VB.NET
- reverse-proxy - Minio 通过 Web 界面上传,API 收到“未经授权的请求”。
- javascript - D3 更新模式未按预期工作
- haskell - 为什么 XMonad 的提示对我不起作用?
- java - fatjar 依赖关系的 Java 日志记录问题
- javascript - 使用模态将多个单击的图像替换为新图像
- wso2 - WSO2 身份服务器 (IS) 帐户禁用选项(复选框)在默认配置文件中不可用
- mysql - 如何在 DATE_FORMAT() 中获取时区?
- flutter - 如何在 Flutter 中使用 RSSI 对蓝牙设备进行排序