自定义servlet重写doGet或者doPost方法时,405 method not allowed
自定义servlet
public class TestServlet extends HttpServlet { @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doGet(req, resp); }
}
HttpServlet里的doGet方法是这样定义的
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
String protocol = req.getProtocol();
String msg = lStrings.getString("http.method_get_not_supported");
if (protocol.endsWith("1.1")) {
resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
} else {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
}
}
所以重写doGet/doPost方法时,必须先将super.doGet(...)/super.doPost(...)删掉
自定义servlet重写doGet或者doPost方法时,405 method not allowed的更多相关文章
- 自定义servlet重写doGet或doPost方法是如何实现多态的
我们知道,如果我们自定义一个servlet继承HttpServlet,并且重写HttpServlet中的doGet或doPost方法,那么从浏览器发送过来的request请求将调用HttpServle ...
- Servlet的doGet与doPost方法的区别与使用
Servlet的doGet与doPost方法的区别与使用 2016年07月07日 13:05:13 阅读数:10222 一,区别 在使用表单提交数据到服务器的时候有两张方式可共选择,一个是post一个 ...
- Servlet的Service方法和doget 和 dopost方法的区别,常见的错误解析
package com.sxt.in; import java.io.IOException; import javax.servlet.ServletException; import javax. ...
- 去除myeclipse中doget和dopost方法中的注释
当我们使用myeclipse新建servlet时发现doget和dopost方法中有一些无用的注释,每次新建一个servlet时都要手动删除特别麻烦. 下面就教大家如何去除这些注释! 以myeclip ...
- servlet中doGet()和doPost()的用法
转自:https://blog.csdn.net/qq_38963960/article/details/79468182 1.servlet中doGet()和doPost()的用法 一般来说我们是用 ...
- service 方法和doGet、doPost方法的区别
Service方法和doGet和doPost方法的区别service: 可以处理get/post方式的请求,如果servlet 中有service方法,会优先调用service方法进行处理do ...
- 关于servlet中doGet和doPost乱码再一次理解
今天系统的整理了在web项目下,出现的编码问题,下面就做一些总结: 首先对HTTP协议中对GET和POST的定义: GET POST 后退按钮/刷新 无害 数据会被重新提交(浏览器应该告知用户数据 ...
- 【Servlet】doGet()与doPost()的区别
doGet与doPost的区别 .Servlet接口只定义了一个服务方法--service .当发出客户端请求时,调用service方法并传递一个请求和响应对象 .使用时经常在doPost()中调用d ...
- servlet中doGet()和doPost()的区别
1.生成方式 get方法有四种: ①直接在URL地址栏中输入URL ②网页中的超链接 ③form中method为get ④form中method为空时,默认是get提交 post只知道有一种:form ...
随机推荐
- 配置访问公网主机上的jupyter notebook
文章结构: 一.安装python 二.安装并配置jupyter并配置jupyter 三.第一个python程序 一.安装python 1.1下载python安装包 # wget https://www ...
- go 语言结构控制
if else 结构: #第一种 if condition { // do something } #第二种 if condition { // do something } else { // d ...
- cf:c题
题目: 代码: #include<iostream> #include<algorithm> #include<vector> #include<string ...
- 委托的异步编程和同步编程的使用( Invoke 和BeginInvoke)
一,区别: 使用Invoke完成一个委托方法的封送,就类似于使用SendMessage方法来给界面线程发送消息,是一个同步方法.也就是说在Invoke封送的方法被执行完毕前,Invoke方法不会返回, ...
- Vue.js 3 Step 创建一个组件
Step1:Vue.extend()创建组件 Step2:Vue.component()注册组件,注册的标签一定要用小写 Step3:挂载点使用组件 <!doctype html> < ...
- 2018-10-8-如何安装-btsync
title author date CreateTime categories 如何安装 btsync lindexi 2018-10-8 9:15:6 +0800 2018-2-13 17:23:3 ...
- 2018-2-13-win10-UWP-显示地图
title author date CreateTime categories win10 UWP 显示地图 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17: ...
- python读写excel(xlrd、xlwt)
一.读excel表 读excel用到xlrd模块,写excel用到xlwt模块: # 1.导入模块 import xlrd # 2.打开Excel文件读取数据 workbook = xlrd.open ...
- Cesium截图功能
首先安装 canvas2image npm intsall canvas2image --save 因为项目基于vue,所以需要在canvas2image的最后面 加上 export default ...
- c# 泛型的抗变和协变
namespace test { // 泛型的协变,T 只能作为返回的参数 public interface Class1<out T> { T Get(); int Count { ge ...