当前位置: 首页 > 知识库问答 >
问题:

Spring MVC HTTP错误500:servlet通知的servlet.init()引发异常

公西志文
2023-03-14

我正在尝试运行一个简单的Spring MVC项目。

以下是错误页面包含的内容:

类型异常报告

servlet通知引发异常的消息servlet.init()

servletException:servlet.init()for servlet通知抛出异常org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:501)org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79)org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.invoke(abstractaccesslogvalve.610)e)org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61)java.lang.thread.run(Unknown Source)根本原因

下面是我的web.xml文件:

<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>WebMVC</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>notices</display-name>
    <servlet-name>notices</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>notices</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

下面是notests-servlet.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>

下面是helloworld.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
</head>
<body>
    Hello World!
</body>

共有1个答案

潘阳舒
2023-03-14

我猜问题出在notests-servlet.xml文件上。检查ServletContext资源的“WEB-INF”文件夹。将notests-servlet.xml放入“web-inf”文件夹后,再次尝试运行项目。希望能行!

.

 类似资料: