![](/img/trans.png)
[英]My Spring based Restful webservice gives 404 when deploy to standalone tomcat instead of Eclipse's 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.