HTTP Status 405 - Die HTTP-Methode GET wird von dieser URL nicht unterstützt

HTTP-Status 405 - Die HTTP-Methode GET wird von dieser URL nicht unterstützt

Der HTTP-Status 405 ist eine sehr häufige Fehlermeldung in Java Servlet.

HTTP Status 405 - HTTP method GET is not supported by this URL

type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource
 (HTTP method GET is not supported by this URL).
Apache Tomcat/6.0.20

Lösung

Dies wird immer aus zwei Gründen verursacht

1) Sie haben keine gültige doGet () -Methode. Wenn Sie den Pfad des Servlets direkt in die Adressleiste eingeben, versucht der Webcontainer wie Tomcat, die doGet () -Methode aufzurufen.

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException{
        ....
    }

2) Sie haben eine HTTP-Post-Anfrage über ein HTML-Formular gestellt, verfügen jedoch nicht über eine doPost () -Methode, um diese zu verarbeiten. Das doGet () kann die "Post" -Anforderung nicht verarbeiten.

    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException{
        ....
    }