简体   繁体   中英

HTTP Status 404 Servlet Redirection Error

HTTP Status 404 - /website/admin/changeown

type Status report

message /website/admin/changeown

description The requested resource is not available.

Apache Tomcat/7.0.56

I have "website/admin/change-own.html" file which has a form whose value needs to be sent to a servlet "WEB-INF/classes/changeown.class". But I keep getting this error.

Can anybody please tell me what seems to be the problem. I've pondered over it for quite some time but can't seem to find the problem.

Here is the web.xml file

<servlet>
    <servlet-name>changeown</servlet-name>
    <servlet-class>changeown</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>changeown</servlet-name>
    <url-pattern>/website/admin/changeown</url-pattern>
</servlet-mapping>


<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>

Here is the form in html

form role="form" action="changeown" method="post"

I've tried changing the url in web.xml as /changeown but it still gives the same error.

You are posting your 'changeowner' form to a wrong URL. If you inspect your form post in developer tools, you will notice that your form post URL is of format http://<server-context>/changeown . You don't have any mapping for this URL pattern in your web.xml. Therefore Catalina gives you a 404 - client error indicating that your URL is mal-formed. Based on your servlet configurations, you need to post your form to the URL http://<server-context>/website/admin/changeown

Change

form role="form" action="changeown" method="post"

to

form role="form" action="website/admin/changeown" method="post"

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