日期:2014-05-18  浏览次数:20742 次

100分求救——怎么找不到我的servlet啊??????????
很简单的一个serlet调用,代码如下:
index.jsp页面中一个简单的表单:
<form   name= "frm "   method= "post "   action= "servlet/com.zc.login.Login "   onsubmit= "return   check(); ">
              <div   align= "center "> 用户名:
                <input   name= "userName "   type= "text "   size= "12 ">
                      <br>
                              密码:
                                  <input   name= "userPwd "   type= "password "   size= "12 ">  
                                  <br>                                     
                              <input   type= "submit "   name= "Submit "   value= "确定 ">
                <input   type= "reset "   name= "Submit2 "   value= "重置 ">                        
            </div>
</form>

Login.java代码:

package   com.zc.login;

import   java.io.*;
import   javax.servlet.*;
import   javax.servlet.http.*;
import   java.util.*;

public   class   Login   extends   HttpServlet{
    protected   void   doPost(HttpServletRequest   req,   HttpServletResponse   res)   throws   ServletException,   IOException{
                String   userName=req.getParameter( "userName ");
                String   userPwd=req.getParameter( "userPwd ");
PrintWriter   out=res.getWriter();
out.println( "姓名是: "+userName);
out.println( "密码是: "+userPwd);
        }
}

web.xml就放在WEB-INF文件夹下,代码为:

<?xml   version= "1.0 "   encoding= "ISO-8859-1 "?>

<!DOCTYPE   web-app
        PUBLIC   "-//Sun   Microsystems,   Inc.//DTD   Web   Application   2.3//EN "
        "http://java.sun.com/dtd/web-app_2_3.dtd ">

<web-app   id= '/ '>
  <directory-servlet   id= 'true '/>
  <servlet-mapping>
        <servlet-name> invoker </servlet-name>
        <url-pattern> /servlet/* </url-pattern>
  </servlet-mapping>
</web-app>

我用的是tomcat