为了账号安全,请及时绑定邮箱和手机立即绑定

这个错误如何解决啊?

https://img1.sycdn.imooc.com//5b2f86ca00012bb303620508.jpg


package com.weixin.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 列表页面初始化控制
 *
 */
@SuppressWarnings("serial")
public class ListServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    // TODO Auto-generated method stub
    req.getRequestDispatcher("/WEB-INF/jsp/back/list.jsp").forward(req, resp);
}
@Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        this.doPost(req, resp);
    }
}


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>MicroMessage</display-name>

  <servlet>
      <servlet-name>ListServlet</servlet-name>
      <servlet-class>com.weixin.servlet.ListServlet</servlet-class>
  </servlet>
  <servlet-mapping>
     <servlet-name>ListServlet</servlet-name>
     <url-pattern>/list</url-pattern>
  </servlet-mapping>
</web-app>

HTTP Status 405 – Method Not Allowed


Type Status Report

Message HTTP method GET is not supported by this URL

Description The method received in the request-line is known by the origin server but not supported by the target resource.


Apache Tomcat/8.5.16


正在回答

2 回答

直接把web.xml的配置文件取消了,用@WebServlet("")注解不就可以了

0 回复 有任何疑惑可以回复我~

你的访问路径应该是:localhost:8080/MicroMessage/list


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

这个错误如何解决啊?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信