无法在tomcat服务器上的eclipse上运行Web项目
我在 WebContent/WEB-INF/Form.html
位置使用 form.html
制作了一个小型 Web 应用程序,
其中有 servletOne.java Servlet.java,
Icecream.java
位于名为“ApplicaitonOne”的项目的 src
文件夹中
Form.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p><kbd>SELECT VALUE</kbd></p>
<p>
<label>
<input type="radio" name="RadioGroup1" value="Vanilla" id="RadioGroup1_0" />
Vanilla</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="Chocolate" id="RadioGroup1_1" />
CHocholate</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="Strawberry" id="RadioGroup1_2" />
Strawberry</label>
<br />
</p>
<p>
<input type="submit" name="Submit" id="Submit" value="Submit" />
<br />
</p>
</form>
<p> </p>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>ApplicationOne</display-name>
<welcome-file-list>
<welcome-file>Form.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>ServletOne</servlet-name>
<servlet-class>com.example.ServletOne</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletOne</servlet-name>
<url-pattern>/Welcome</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
15
</session-timeout>
</session-config>
<context-param>
<param-name>flavour</param-name>
<param-value>Choclate</param-value>
</context-param>
<listener>
<listener-class>
com.example.ServletInt
</listener-class>
</listener>
</web-app>
当项目作为服务器运行时,我 得到:
地址栏中的地址:http://localhost:8080/ApplicationOne/
HTTP 状态 404 - /ApplicationOne/
类型状态报告
消息 /ApplicationOne/
描述 请求的资源(/ApplicationOne/)不可用。
Apache Tomcat/5.5.31
当作为服务器运行 form.html
时,我得到:
地址栏中的地址:http://localhost:8080/ApplicationOne/WEB-INF /Form.html
HTTP 状态 404 -
类型状态报告
留言
描述 请求的资源()不可用。
Apache Tomcat/5.5.31
i have made a small web application with form.html
in the WebContent/WEB-INF/Form.html
location
There are servletOne.java Servlet.java
, Icecream.java
in the src
folder of my project named "ApplicaitonOne"
Form.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p><kbd>SELECT VALUE</kbd></p>
<p>
<label>
<input type="radio" name="RadioGroup1" value="Vanilla" id="RadioGroup1_0" />
Vanilla</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="Chocolate" id="RadioGroup1_1" />
CHocholate</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="Strawberry" id="RadioGroup1_2" />
Strawberry</label>
<br />
</p>
<p>
<input type="submit" name="Submit" id="Submit" value="Submit" />
<br />
</p>
</form>
<p> </p>
</body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>ApplicationOne</display-name>
<welcome-file-list>
<welcome-file>Form.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>ServletOne</servlet-name>
<servlet-class>com.example.ServletOne</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletOne</servlet-name>
<url-pattern>/Welcome</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
15
</session-timeout>
</session-config>
<context-param>
<param-name>flavour</param-name>
<param-value>Choclate</param-value>
</context-param>
<listener>
<listener-class>
com.example.ServletInt
</listener-class>
</listener>
</web-app>
When running project as server, I get:
address in address bar: http://localhost:8080/ApplicationOne/
HTTP Status 404 - /ApplicationOne/
type Status report
message /ApplicationOne/
description The requested resource (/ApplicationOne/) is not available.
Apache Tomcat/5.5.31
When running form.html
as server, I get:
address in address bar: http://localhost:8080/ApplicationOne/WEB-INF/Form.html
HTTP Status 404 -
type Status report
message
description The requested resource () is not available.
Apache Tomcat/5.5.31
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WEB-INF 是一个私有目录(它将包含配置和编译代码)。 form.html 应直接位于 WebContent/ 下。
要仔细检查应用程序的上下文路径,您可以访问:
http://localhost:8080/manager/html
WEB-INF is a private directory (It will contains configs and compile code). form.html should be directly under WebContent/.
To double check the context path of your application you can visit:
http://localhost:8080/manager/html
您应该将 html 或 jsp 文件放在 WebContent 文件夹下:
比如:workspace[项目名称]\WebContent\form.html 并通过tomcat运行它。
它将正常工作。
You should place your html or jsp file just under the WebContent Folder:
like:workspace[Project Name]\WebContent\form.html and Run it through tomcat.
It will work properly.