【问题标题】:HTTP 404 Java ServletsHTTP 404 Java Servlet
【发布时间】:2015-03-24 20:52:26
【问题描述】:

点击提交时出现此错误

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

这是表单标签,我的 HTML 表单有一个提交按钮。

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

这是我的目录结构

这是我的 webxml 文件

<?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>

我似乎无法弄清楚出了什么问题。请帮忙。

【问题讨论】:

  • 您的 dbconnection 类中有什么? url 表单提交是否正确?你的 dbconnection 接受 post 方法吗? ps:从控制器连接到数据库????

标签: java servlets http-status-code-404


【解决方案1】:

IIRC,servlet 名称需要完全指定:

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

另外,请确保您的 url-pattern 正确。

【讨论】:

  • 你是对的 - 假设这是这个问题的根源,值得注意的是,这将在服务器日志文件中产生异常堆栈跟踪,因此首先查看那里总是一个好主意.
猜你喜欢
  • 2014-05-10
  • 1970-01-01
  • 2023-04-05
  • 2015-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-16
  • 2012-10-07
相关资源
最近更新 更多