Spring MVC。 HTTP状态500 - 实例化servlet时出错

时间:2014-02-08 11:20:25

标签: java spring spring-mvc servlets spring-tool-suite

我创建了maven项目“File-> New-> Other ..-> Maven-> Maven Project”
我创建了控制器+视图,“Hello World”,一切运行良好 我愚蠢地决定点击RightClick(在项目上) - > Maven->更新项目(tomcat正在运行)。
在项目出现“红色感叹号”和“HelloWorld”不起作用。

enter image description here

“我更新”后的屏幕

enter image description here

enter image description here

enter image description here

enter image description here

的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mdosoft</groupId>
  <artifactId>Primer</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>Primer Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.2.6.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>Primer</finalName>
  </build>
</project>

2 个答案:

答案 0 :(得分:1)

运行 mvn clean package 确保所有jar都在lib文件夹中。如果不起作用,请将servlet api版本更改为2.5

答案 1 :(得分:0)

你能提供pom.xml文件, 检查servlet api-3.0.1 depaendency的范围,它必须是provided