这样访问看能否通过
 http://192.168.0.20:8080/HelloServlet/servlet/mypack.hello

解决方案 »

  1.   

    不能啊,要是http://192.168.0.20:8080/HelloServlet/a.htm能通过
      

  2.   

    或者 在web.xml中的<servlet-name> 标签中是否也要加上包名
      

  3.   

    还是不行啊!
    我的tomcat运行http://192.168.0.20:8080/jsp-examples/
    时候出现
    Directory Listing For /dates/ - Up To /--------------------------------------------------------------------------------
    Filename Size Last Modified --------------------------------------------------------------------------------Apache Tomcat/5.0.25
    这是怎么回事情?
      

  4.   

    能否把HelloServlet发给我, 前提是不需要保密的话!!
      

  5.   

    package mypack;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;public class HelloServlet extends HttpServlet
    {    public void doPost(HttpServletRequest request, HttpServletResponse response) throws
          ServletException,IOException {
         String clientName=request.getParameter("clientName");
         if(clientName!=null)
         clientName=new String(clientName.getBytes("ISO-8859-1"),"GB2312");
         else
         clientName="我的朋友";      PrintWriter out;
          String title="HelloServlet";
          String heading1="This is output from HelloServlet by doGet:";      response.setContentType("text/html;charset=GB2312");      out = response.getWriter();
          out.print("<HTML><HEAD><TITLE>"+title+"</TITLE>");
          out.print("</HEAD><BODY>");
          out.print(heading1);
          out.println("<h1><P> "+clientName+" : 您好</h1>");
          out.print("</BODY></HTML>");      out.close();    }
    }
      

  6.   

    在配置web_xml中错误
    应该是<url-pattern>/HelloWord/hello</url-pattern>
      

  7.   

    不好意思
    上面的打错了
    应该是::
    在配置web_xml中错误
    应该是<url-pattern>/HelloServlet/hello</url-pattern>
      

  8.   

    类编译到哪里去了?应该是在WEB-INF/classes/,404错误,应该是没找到这个类啊
      

  9.   

    将HelloServlet.class拷入ROOT/WEB-INF/classes/下在ROOT/WEB-INF/web.xml的<!-- JSPC servlet mappings start -->下加入以下:
           <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>
      

  10.   

    HTTP Status 405 - HTTP method GET is not supported by this URL--------------------------------------------------------------------------------type Status reportmessage HTTP method GET is not supported by this URLdescription The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
    --------------------------------------------------------------------------------Apache Tomcat/5.0.25
    这是什么意思?
      

  11.   

    http://192.168.0.20:8080/HelloServlet/hello
    改为http://192.168.0.20:8080/HelloServlet/HelloServlet
      

  12.   

    这个http://192.168.0.20:8080/HelloServlet/hello
    应该可以。
      

  13.   

    你的class文件必须放在%web-app%\WEB-INF\classes\目录下,或者是它的子目录,或者是打包后放在%web-app%\WEB-INF\lib\目录下。
      

  14.   

    试试在classes目录中加个mypack的目录,然后把你的类文件放在该目录下
    然后用http://localhost:8080/HelloServlet/hello  访问!java中对路径要求很严格的!