报错HTTP Status 405 - HTTP method GET is not supported by this URL

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.sql.*;
public class Register extends HttpServlet{
public static int n = 0;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = null;
PrintWriter out;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
super.doGet(request, response);
}

protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
out=response.getWriter();
out.print("<HTML>");
out.print(new String(request.getParameter("test").getBytes("ISO-8859-1"), "UTF-8"));
if (new String(request.getParameter("test").getBytes("ISO-8859-1"), "UTF-8") == "Y")
{
out.print("<HTML>");
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
String name = new String(request.getParameter("username").getBytes("ISO-8859-1"), "UTF-8");
String password = new String(request.getParameter("pwd1").getBytes("ISO-8859-1"), "UTF-8");
String realname = new String(request.getParameter("realname").getBytes("ISO-8859-1"), "UTF-8");
String number = new String(request.getParameter("number").getBytes("ISO-8859-1"), "UTF-8");
String sex;
if (new String(request.getParameter("gender").getBytes("ISO-8859-1"), "UTF-8") == "man")
sex = "1";
else sex = "2";
String birthM =new String(request.getParameter("month").getBytes("ISO-8859-1"), "UTF-8");
String birthD =new String(request.getParameter("day").getBytes("ISO-8859-1"), "UTF-8");
String constellation = new String(request.getParameter("constellation").getBytes("ISO-8859-1"), "UTF-8");
String sign = new String(request.getParameter("sign").getBytes("ISO-8859-1"), "UTF-8");
String level = "1";
String grades = "0";
String articles = "1";
String finaltime = "0";
n++;
try
{
out.print("<HTML>");
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/blog","root","1");
stmt = conn.createStatement();
sql = "INSERT INTO person(ID,name,password,realname,number,sex,birthM,birthD,constellation,sign,level,grades,articles,finaltime) VALUES('"+String.valueOf(n)+"','"+name+"','"+password+"','"+realname+"','"+number+"',"+sex+","+birthM+","+birthD+",'"+constellation+"','"+sign+"',"+level+","+grades+","+articles+","+finaltime+")";
out.print(sql);
stmt.executeUpdate(sql);
}
catch(Exception e) {}
}
}
}

这是SERVLET的代码,用的时候报了那个错误,谁能告诉我是什么问题?

第1个回答  推荐于2018-03-19
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request,response);
}本回答被提问者和网友采纳
第2个回答  2019-11-16
servlet里没有提供对doget方法的支持..........
第3个回答  2019-09-26

神奇,super.doget改成doPost

HTTP Status 405 - HTTP method GET is not supported by this URL
public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {doGet(req,resp);}} 在调试servlet,运行http:\/\/localhost:8080\/test\/r时出现HTTP Status 405 - HTTP method GET is not supported by this URL的错误。源程序:package serv import java.io ...

...HTTP method GET is not supported by this URL
HTTP Status 405 - HTTP method GET is not supported by this URL 不支持GET,要使用POST

...HTTP method GET is not supported by this URL
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { \/\/ TODO Auto-generated method stub doPost(request,response);}

...405 - Request method 'GET' not supported是什么原因
405:用来访问本页面的 HTTP 谓词不被允许(方法不被允许)请求方法(GET、POST、HEAD、DELETE、PUT、TRACE等)对指定的资源不适用。还有其他的报错信息么,应该是你使用的方法出现问题

网站访问出现错误代码405,请问怎么解决?
一、工具 1、idea 2、java 二、方法:1、本例就以java的文本开发的网站来举例说明,其实网页HTTP的405错误和开发语言没有直接关系,只是实现方式不一样而已。知道导致405的原因和解决思路即可。首先看下405错误的示例,有method = RequestMethod.POST限制。2、405 Request method 'GET' not supported(...

...405 - Request method 'GET' not supported是什么原因
可以将SpringMVC中的@RequestMapping的method改为RequestMethod.GET试试 一般405报错就是请求方式的问题

关于http请求返回 Request failed: method not allowed (405)。
第一种情况:遇到405请求错误。提示:NSLocalizedDescription=Request failed: method not allowed (405)。解决方案:405请求方法不被允许。这时候应该检查请求方法是否正确,页面应该用GET请求还是POST请求。例如在请求微博access_token的时候虽然不需要发送数据但这个页面却要求使用POST请求。第二种情况:使用AF...

HTTP Status 405 - HTTP method POST is not supported by this URL
public class CloudLed { boolean m_isOn;Camera m_Camera;public boolean getIsOn() { return m_isOn; } public CloudLed(){ m_isOn = false;} public void turnOn(){ if(!m_isOn){ m_isOn = true;try {

springmvc中报错HTTP Status 405 - JSPs only permit GET POST or HEA...
405:用来访问本页面的 HTTP 谓词不被允许(方法不被允许)请求方法(GET、POST、HEAD、DELETE、PUT、TRACE等)对指定的资源不适用。还有其他的报错信息么,应该是你使用的方法出现问题

如何解决 "HTTP错误403-禁止访问 "问题
使用response.sendRedirect(url)比使用response.setStatus(response.SC_MOVED_TEMPORARILY)和response.setHeader("Location",url)更好。注意这个状态代码有时候可以和301替换使用。303 See Other:类似于301\/302,不同之处在于,如果原来的请求是POST,Location头指定的重定向目标文档应该通过GET提取。304 ...

相似回答