关于servlet的一个问题
package servlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Registration extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html><body>hhhhhh</body></html>");
}
}
tomcat5.0 web.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/dtd/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>NewRegistration</servlet-name>
<servlet-class>servlets.Registration</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>NewRegistration</servlet-name>
<url-pattern>/NewRegistration</url-pattern>
</servlet-mapping>
</web-app>
在IE打入
http://localhost:8080/ChatRoom_ServerVersion/NewRegistration
出错:
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).
如果把doPost改成doGet就运行正常,请教是怎么回事?