又一次
HTTP状态500 - 实例化servlet类org.springframework.web.servlet.DispatcherServlet时出错
请你们(那些了解它的人)写一个指南来帮助我们调试这个?它甚至意味着什么?是什么原因导致它无法实例化该类?
无论如何我头疼。我只有一个控制器和一个带有/
url模式的默认调度程序servlet。仍然它失败了与HTTP 500 ...我甚至想知道它在所有servlet进入component-scan base package
。下面是我的项目架构和一些代码:
的pom.xml
<!-- BASIC DEPENDENCIES -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- CURRENT JDK -->
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
的web.xml
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>DefaultServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/webcontext/DefaultServlet-context.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>DefaultServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
defaultServlet-context.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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.parochia.controllers" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:resources mapping="/resources/**" location="/ressources/theme1/" />
</beans>
控制器
@Controller
public class liturgieController {
@RequestMapping("/")
public String liturgie(Model model){
return "liturgie";
}
}
** PS:**请各位朋友,这里有太多错误。我们甚至无法扫描其他响应并将其应用到我们的cas中,因为它每次发生时似乎都不同。在进入stackoverflow之前我们应该如何调试它。它甚至意味着什么......
......我很沮丧:(
答案 0 :(得分:-1)
在web.xml
中的servlet定义中,用
<sevlet-mapping>/<sevlet-mapping>
<sevlet-mapping>/*<sevlet-mapping>
并发送其他异常以查看。