关于网友提出的“ 奇怪的错误HTTP Status 405 - HTTP method GET is not supported by this URL”问题疑问,本网通过在网上对“ 奇怪的错误HTTP Status 405 - HTTP method GET is not supported by this URL”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 奇怪的错误HTTP Status 405 - HTTP method GET is not supported by this URL描述:
package com.flight.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import org.apache.commons.beanutils.BeanUtils;
import com.flight.bean.City;
import com.flight.bean.flight;
import com.flight.dao.searchflightDao;
public class ticketsearchServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response, String String)
throws ServletException, IOException {
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String action=request.getParameter("action");
searchflightDao sfdao=new searchflightDao();
if(action.equals("list")){
String flight_id = request.getParameter("flight_id");
String datetime = request.getParameter("datetime");
request.setAttribute("fmList", sfdao.findBy(flight_id,datetime));
request.getRequestDispatcher("ticketstatus.jsp").forward(request, response);
}
}
public void init() throws ServletException {
// Put your code here
}
}
表单的提交方式检查过了是post方式提交的,请高手们帮忙看看是怎么回事?急用啊!!!
解决方案1:
话说你的doget方法里面为什么会有一个String参数呢?
解决方案2: 1,子类重写doGet或doPost等方法;
2,在你扩展的Servlert中重写doGet或doPost等方法来处理请求和响应时 不要调用父类HttpServlet的doGet或doPost等方法,即去掉super.doGet(request, response)和super.doPost(request, response);