第一个Servlet程序,出现HTTP Status 404 - Servlet myfirstserverlet is not available 错误 20
HelloWorld.java文件packagecom.zhou;importjava.io.IOException;importjava.io.PrintWriter;...
HelloWorld.java文件
package com.zhou;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloWorld extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter out=resp.getWriter();
out.println("<html><head></head><body>hello world!!!</body></html>");
out.flush();
out.close();
}
}
web.xml文件:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<servlet>
<servlet-name>myfirstserverlet</servlet-name>
<servlet-class>com.zhou.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myfirstserverlet</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
文件位置:
G:\Program Files\apache-tomcat-7.0.5\webapps\my\WEB-INF;
G:\Program Files\apache-tomcat-7.0.5\webapps\my\WEB-INF\web.xml;
G:\Program Files\apache-tomcat-7.0.5\webapps\my\WEB-INF\classess\com\zhou\HelloWorld.class;
在IE里输入:http://localhost:8080/my/HelloWorld
Tomcat也正常启动了,不知道到底哪儿错了,望哪位大侠帮忙看看,感激不尽。。。 展开
package com.zhou;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloWorld extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter out=resp.getWriter();
out.println("<html><head></head><body>hello world!!!</body></html>");
out.flush();
out.close();
}
}
web.xml文件:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<servlet>
<servlet-name>myfirstserverlet</servlet-name>
<servlet-class>com.zhou.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myfirstserverlet</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
文件位置:
G:\Program Files\apache-tomcat-7.0.5\webapps\my\WEB-INF;
G:\Program Files\apache-tomcat-7.0.5\webapps\my\WEB-INF\web.xml;
G:\Program Files\apache-tomcat-7.0.5\webapps\my\WEB-INF\classess\com\zhou\HelloWorld.class;
在IE里输入:http://localhost:8080/my/HelloWorld
Tomcat也正常启动了,不知道到底哪儿错了,望哪位大侠帮忙看看,感激不尽。。。 展开
2个回答
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没看你写的这么多东西,就看见一个404 我就进来了.404 是路径错误,自己看看,路径错啦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询