还是不行啊! 我的tomcat运行http://192.168.0.20:8080/jsp-examples/ 时候出现 Directory Listing For /dates/ - Up To /-------------------------------------------------------------------------------- Filename Size Last Modified --------------------------------------------------------------------------------Apache Tomcat/5.0.25 这是怎么回事情?
能否把HelloServlet发给我, 前提是不需要保密的话!!
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(); } }
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 这是什么意思?
我的tomcat运行http://192.168.0.20:8080/jsp-examples/
时候出现
Directory Listing For /dates/ - Up To /--------------------------------------------------------------------------------
Filename Size Last Modified --------------------------------------------------------------------------------Apache Tomcat/5.0.25
这是怎么回事情?
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(); }
}
应该是<url-pattern>/HelloWord/hello</url-pattern>
上面的打错了
应该是::
在配置web_xml中错误
应该是<url-pattern>/HelloServlet/hello</url-pattern>
<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>
--------------------------------------------------------------------------------Apache Tomcat/5.0.25
这是什么意思?
改为http://192.168.0.20:8080/HelloServlet/HelloServlet
应该可以。
然后用http://localhost:8080/HelloServlet/hello 访问!java中对路径要求很严格的!