import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet {
//从HttpServlet类的帮助文档中复制service方法的声明部分可避免书写错误
//private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request,response);
}
public void Service(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<font size=30 color=red>www.it315.org</font><br>");
out.println("<marquee>"+ new java.util.Date() +"</marquee>");
out.println("</html>");
}
}
请高手们帮帮忙看看,用浏览器运行时,出现错误:
HTTP Status 405 - HTTP method GET is not supported by this URL
--------------------------------------------------------------------------------
type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
是怎么回事呢?我是新手菜鸟,很想学好java,希望大家帮我看看哦~~
------解决方案--------------------------------------------------------
public void Service(HttpServletRequest request,
HttpServletResponse response)
写成public void doPost(HttpServletRequest request,
HttpServletResponse response)吧
------解决方案--------------------------------------------------------
你的代码是手写的?
建议你先区分一下,doGet,doPost,service这三个方法。
http://blog.csdn.net/dragonfly0939/article/details/3169608
注意表单中,<form method="post/get">
要给method,post或者get