2016-05-23 37 views
0

我有一个非常基本的Spring项目,它使用JSTL和jsp作为视图,当我在页面上包含JSTL标记时,我开始收到一个404错误。它工作正常,没有标签。为什么在库中需要一些罐子,有些不在战争中?

This后建议包括在WEB-INF \ lib目录下,它解决了我的问题,这有一定道理的JSTL罐子......但是我在想,为什么只有这个jar需要添加到lib目录?还有其他的依赖关系不是必需的。

所有依赖项都由Maven管理。

以下是项目结构,显示了所用的所有库。

project structure

而且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/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>SpringClient</groupId> 
<artifactId>Client</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>war</packaging> 
<dependencies> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>4.2.6.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>4.2.6.RELEASE</version> 
    </dependency> 
    <!-- http://mvnrepository.com/artifact/org.springframework/spring-webmvc --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>4.2.6.RELEASE</version> 
    </dependency> 
    <!-- Included because as a dependency of spring --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
     <version>3.1.0</version> 
    </dependency> 
    <!-- http://mvnrepository.com/artifact/jstl/jstl --> 
    <dependency> 
     <groupId>jstl</groupId> 
     <artifactId>jstl</artifactId> 
     <version>1.2</version> 
    </dependency> 

</dependencies> 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.6</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

正如你所看到的,JSTL罐子在两个地方目前已经上市,为什么是这个必要吗?

+1

请发表你的pom.xml – Jaiwo99

+0

如果您必须手动将文件放到'WEB-INF/lib'比你一个不@ Jaiwo99与Maven ... – khmarbaise

+0

管理你的依赖谢谢,增加了pom – Continuity8

回答

相关问题