什么是JSTL强制罐 [英] What are JSTL mandatory Jars

查看:84
本文介绍了什么是JSTL强制罐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,刚开始学习Java.从 jstl 标记中,我对jstl了解很多.

我使用IDE(eclispe mars)通过添加一个简单的jsp页面来创建动态Web项目,然后将war导出到tomcat7的webapps文件夹中.我对jstl强制jar的依赖性进行了一些测试.

我的核心项目文件是:

web.xml: 

  <web-app xmlns:xsi="http:....... version="3.0">   //use servlet 3.0

index.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>   
<!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=UTF-8">
<title>jstl Tag Lib</title>
</head>
<body>
<h2>2+2=${2+2}</h2> //this line works, el is a part of jsp.

//below lines work fine if there are proper jstl jars.
<c:set var="salary" scope="session" value="${2000*2}" />
salary:<c:out value="${salary}" />
</body>
</html>

在WEB-INF/lib/文件夹中,我有3种jar,这3个组都可以正常工作.

1)仅包含:

jstl-1.2.jar

什么组织交付它? apache tomcat?

2)仅包含:

javax.servlet.jsp.jstl-api-1.2.1.jar
javax.servlet.jsp.jstl-1.2.4.jar

在这里,我有一个问题:两个罐子有什么区别?

3)仅包含:

taglibs-standard-impl-1.2.5.jar
taglibs-standard-compat-1.2.5.jar
taglibs-standard-jstlel-1.2.5.jar
taglibs-standard-spec-1.2.5.jar

http://tomcat.apache.org/download-taglibs.cgi下载的轮胎罐 在这里,我有一个问题:三个罐子有什么区别? 因为我不知道它们之间的区别,所以将三个罐子放到lib文件夹中,但是我发现taglibs-standard-impl.*.jar在运行时是必需的.

解决方案

我考虑了一整夜的问题,我意识到也许答案就在罐子旁边.问题的最后一部分,关于4个apache Tomcat罐,来自链接,是2个自述文本文件(源README 二进制自述文件)

它说:

There are three primary sub-modules:

    spec            <-- contains Apache's implementation of the API classes
    impl            <-- contains the implementation of tags from the 1.1
                        namespace http://java.sun.com/jsp/jstl/*
    jstlel          <-- contains the implementation of tags from the 1.0
                        namespace http://java.sun.com/jstl/* and uses the
                        original JSTL 1.0 version of EL

In addition, the following modules provide supporting functionality
    build-tools     <-- build support such as checkstyle rules
    compat          <-- contains the implementation of tags from the 1.0
                        namespace but uses the JSP container's implementation
                        of EL (which will be 2.1 or later).

二进制自述文件:

This version of the Standard Tag Library has the following runtime
dependencies:

   1. Dependencies provided by a JSP 2.1 container:
      - Java 1.5 or later
      - Servlet 2.5 or later
      - JSP 2.1 or later

   2. Additional dependencies
      - The XML tag library requires Apache Xalan 2.7.1 or later

---
Apache Xalan 2.7.1

To address performance issues with XSLT processing, this version relies on
implementation specific functionality from Apache Xalan. The following
libraries should be included in the classpath for your application:
   - xalan-2.7.1.jar
   - serializer-2.7.1.jar

---------------------------------------------------------------------------
ADD DEPENDENCIES TO A WEB APPLICATION

To use this distribution with your own web applications, add the following JAR
files to the '/WEB-INF/lib' directory of your application:
   - taglibs-standard-spec-1.2.5.jar
   - taglibs-standard-impl-1.2.5.jar
   - taglibs-standard-jstlel-1.2.5.jar
   - xalan-2.7.1.jar
   - serializer-2.7.1.jar

If you do not use JSTL 1.0 tags then the "taglibs-standard-jstlel" JAR may be
omitted. If you do not use the XML library, then the Apache Xalan dependencies
may also be omitted.

If you build you application with Maven, add the following dependencies to
your pom.xml file:

    <dependency>
      <groupId>org.apache.taglibs</groupId>
      <artifactId>taglibs-standard-spec</artifactId>
      <version>1.2.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.taglibs</groupId>
      <artifactId>taglibs-standard-impl</artifactId>
      <version>1.2.5</version>
    </dependency>

我还使用jd-gui反编译jar,然后在taglibs-standard-impl-1.2.5.jar中找到一些类,它们的基类在taglibs-standard-spec-1.2.5.jar中.

也可以使用反编译方法,

jstl-1.2.jar是一个jar,但是jar中有两个主要包. -1)org.apache.taglibs.standard -2)javax.servlet.jsp.jstl

javax.servlet.jsp.jstl-1.2.4.jar和javax.servlet.jsp.jstl-api-1.2.1.jar是另一个组jar.

每个容器的每个jar中只有一个主程序包,它们是javax.servlet.jsp.jstl-1.2.4.jar中的org.apache.taglibs.standard命名空间,而javax.servlet.jsp.jstl中的名称是apce javax.servlet.jsp.jstl-api-1.2.1.jar.所以我们可以说两个罐子的组合等于jstl.jar

这种情况类似于apache tomcat jars组.区别在于apache tomcat实现将更多的类划分为3个或4个不同的jar文件.

因此,到目前为止,我可以说我了解这些Apache Tomcat罐子的大多数基本用法.

I am new, and just start learning Java. From the jstl tag, I know a lot about jstl.

I use IDE(eclispe mars) to create a dynamic web project by adding a simple jsp page, then export the war to the tomcat7's webapps folder. I do some testings of the dependence of jstl mandatory jars.

My core project files are:

web.xml: 

  <web-app xmlns:xsi="http:....... version="3.0">   //use servlet 3.0

index.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>   
<!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=UTF-8">
<title>jstl Tag Lib</title>
</head>
<body>
<h2>2+2=${2+2}</h2> //this line works, el is a part of jsp.

//below lines work fine if there are proper jstl jars.
<c:set var="salary" scope="session" value="${2000*2}" />
salary:<c:out value="${salary}" />
</body>
</html>

In the WEB-INF/lib/ folder, I have 3 kinds of jars, all of the 3 groups work fine.

1) only contains:

jstl-1.2.jar

what organization deliver it? apache tomcat?

2) only contains:

javax.servlet.jsp.jstl-api-1.2.1.jar
javax.servlet.jsp.jstl-1.2.4.jar

Here, I have a question: What are the two jars difference?

3) only contains:

taglibs-standard-impl-1.2.5.jar
taglibs-standard-compat-1.2.5.jar
taglibs-standard-jstlel-1.2.5.jar
taglibs-standard-spec-1.2.5.jar

Thoes jars download from http://tomcat.apache.org/download-taglibs.cgi Here, I have a quesiton: What are the three jars difference? Because I don't know the difference, I drop the three jars to the lib folder, but I find taglibs-standard-impl.*.jar is mandatory when runnnig time.

解决方案

I think about the qestion over the night, and I realize that maybe the answer is just beside the jar. The last part of the question, about the 4 apache tomcat jars, From the link, there are 2 readme text files(Source README, Binary README)

It says:

There are three primary sub-modules:

    spec            <-- contains Apache's implementation of the API classes
    impl            <-- contains the implementation of tags from the 1.1
                        namespace http://java.sun.com/jsp/jstl/*
    jstlel          <-- contains the implementation of tags from the 1.0
                        namespace http://java.sun.com/jstl/* and uses the
                        original JSTL 1.0 version of EL

In addition, the following modules provide supporting functionality
    build-tools     <-- build support such as checkstyle rules
    compat          <-- contains the implementation of tags from the 1.0
                        namespace but uses the JSP container's implementation
                        of EL (which will be 2.1 or later).

Binary README:

This version of the Standard Tag Library has the following runtime
dependencies:

   1. Dependencies provided by a JSP 2.1 container:
      - Java 1.5 or later
      - Servlet 2.5 or later
      - JSP 2.1 or later

   2. Additional dependencies
      - The XML tag library requires Apache Xalan 2.7.1 or later

---
Apache Xalan 2.7.1

To address performance issues with XSLT processing, this version relies on
implementation specific functionality from Apache Xalan. The following
libraries should be included in the classpath for your application:
   - xalan-2.7.1.jar
   - serializer-2.7.1.jar

---------------------------------------------------------------------------
ADD DEPENDENCIES TO A WEB APPLICATION

To use this distribution with your own web applications, add the following JAR
files to the '/WEB-INF/lib' directory of your application:
   - taglibs-standard-spec-1.2.5.jar
   - taglibs-standard-impl-1.2.5.jar
   - taglibs-standard-jstlel-1.2.5.jar
   - xalan-2.7.1.jar
   - serializer-2.7.1.jar

If you do not use JSTL 1.0 tags then the "taglibs-standard-jstlel" JAR may be
omitted. If you do not use the XML library, then the Apache Xalan dependencies
may also be omitted.

If you build you application with Maven, add the following dependencies to
your pom.xml file:

    <dependency>
      <groupId>org.apache.taglibs</groupId>
      <artifactId>taglibs-standard-spec</artifactId>
      <version>1.2.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.taglibs</groupId>
      <artifactId>taglibs-standard-impl</artifactId>
      <version>1.2.5</version>
    </dependency>

I also use jd-gui to decompile the jars, then I find some classes in taglibs-standard-impl-1.2.5.jar, their base classes are in taglibs-standard-spec-1.2.5.jar.

Also use the decompiling methodology, I can find that,

jstl-1.2.jar is a single jar, but it has two main packages in the jar. - 1) org.apache.taglibs.standard - 2) javax.servlet.jsp.jstl

javax.servlet.jsp.jstl-1.2.4.jar and javax.servlet.jsp.jstl-api-1.2.1.jar is another group jar.

each of them has only one main package in each jar, they are org.apache.taglibs.standard namespace in javax.servlet.jsp.jstl-1.2.4.jar, and javax.servlet.jsp.jstl namesapce in javax.servlet.jsp.jstl-api-1.2.1.jar. So we can say the combination of the two jars is equal to the jstl.jar

The situation is similar to the apache tomcat jars group. The difference is that the apache tomcat implementation divide more classes into 3 or 4 different jar files.

So as of now, I can say I understand most of the basic usages of those apache tomcat jars.

这篇关于什么是JSTL强制罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆