解决405错误

解决405错误
package com.xyxy.servlet;
//import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/ser01")
public class Servlet01 extends HttpServlet{
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//super.service(req, resp);
//打印内容在控制台
System.out.println(“hello servlet”);
//通过流输出数据到浏览器
resp.getWriter().write(“hello servlet”);
}
}

去掉super.service(req,resp);即可,如下图所示

解决405错误

上一篇:Python脚本接口返回正常,状态码405


下一篇:大学生数学竞赛题目分类30章之第01章数列极限202104版已发33题