代码之家  ›  专栏  ›  技术社区  ›  gabriel119435

tomcat servlet api如何链接到servlet api?

  •  0
  • gabriel119435  · 技术社区  · 8 年前

    在一个在线课程中,我有以下项目的pom作品:

    <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-servlet-api</artifactId>
            <version>7.0.30</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jstl-impl</artifactId>
            <version>1.2</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    

    这个项目应该在Tomcat7上运行,确实如此。我注意到它被排除在外 servlet-api 从…起 jstl-api jstl-impl 它使用 tomcat-servlet-api provided . 这是我的Tomcat的LIB:

    enter image description here

    因为它只是 servlet-api.jar ,这两个不同名称之间的映射发生在哪里?

    1 回复  |  直到 8 年前
        1
  •  1
  •   user3335083 user3335083    8 年前

    只要使用servlet api类,就会使用tomcat servlet api中包含的servlet api类。tomcat servlet api封装了servlet api类。