简体   繁体   中英

Java: Google App Engine “HTTP method POST is not supported by this URL” error

I just started playing with Google App Engine and Java. I've used Servlets in the past and I understand how they work. I'm trying to make a servlet to POST to, but it's not going over very well.

Here's my Servlet:

public class CreateUser extends HttpServlet
{
    private static final long serialVersionUID = 1L;

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        ...
    }
}

Here's what I get when I post to this from a form:

HTTP ERROR 405
Problem accessing /user/create. Reason:
HTTP method POST is not supported by this URL

I don't understand why I'm getting this when I clearly have implemented doPost. I've double and triple checked the DD (web.xml) file to make sure I have the url mappings correct. I can't find anything online specifically about this. I figure I am over looking something quite simple.

Here's my web.xml:

<web-app...>
    ...
    <servlet>
        <servlet-name>CreateUser</servlet-name>
        <servlet-class>com.joelj.music.api.CreateUser</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Index</servlet-name>
        <url-pattern>/user/create</url-pattern>
    </servlet-mapping>
</web-app>

Thanks.

I feel really stupid. After looking at the code I just posted I realized that the entry was pointed to Index. I can't believe I over looked it so many times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM