简体   繁体   中英

HTTP 404 Java Servlets

I get this error when I click on submit

HTTP Status 404 - /GradeRetrieval/DbConnection
type Status report
message /GradeRetrieval/DbConnection
description The requested resource is not available.

This is the form tag, my HTML form has a submit button.

<form action="../DbConnection" method="post">

This is my directory structure 目录结构

This is my webxml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>GradeRetreival</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>DbConnection</display-name>
<servlet-name>DbConnection</servlet-name>
<servlet-class>DbConnection</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DbConnection</servlet-name>
<url-pattern>DbConnection</url-pattern>
</servlet-mapping>
</web-app>

I can't seem to figure out what is wrong. Kindly help.

IIRC, the servlet name needs to be fully specified:

<servlet-class>action.DbConnection</servlet-class>

Also, make sure your url-pattern is correct.

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