日期:2014-05-17  浏览次数:20801 次

Http404错误!急求解决办法~各位帮帮忙哈`
我建立的目录如下D:\Tomcat\apache-tomcat-6.0.35\webapps\02;02文件夹中有:welcome.html和WEB-INF文件夹;WEB-INF中有web.xml和classes;classes中有WelcomeServlet.java和WelcomeServlet.class


welcome.html内容 :
<html>
<head>
<title>欢迎您!</title>
</head>
<body>
<form action="welcome" method="get">
请输入用户名:<input type="text" name="username"><br>
<input type="submit" value="提交">
</form>
</body>
</html>


WelcomeServlet.java内容:
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 WelcomeServlet extends HttpServlet
{
private String greeting;
public void init()
{greeting=getInitParameter("greeting");}
public void DoGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
{
req.setCharacterEncoding("gb2312");
String username=req.getParameter("username");
String welcomeInfo=greeting+", "+username;
resp.setContentType("text/html");
PrintWriter out=resp.getWriter();
out.println("<html><head><title>");
out.println("Welcome Page");
out.println("</head></title>");
out.println("<body>");
out.println(welcomeInfo);
out.println("</body></html>");
out.close();
}

}



web.xml内容:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements. See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<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_2_5.xsd"
  version="2.5">


<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/helloservlet</url-pattern>
</servlet-mapping>


<servlet>
<servlet-name>WelcomeServlet</se