[英]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.