這個錯誤如何解決???
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.
2018-11-08
直接把web.xml的配置文件取消了,用@WebServlet("")注解不就可以了
2018-06-25
你的訪問路徑應(yīng)該是:localhost:8080/MicroMessage/list