简体   繁体   English

Tomcat 5.5 Servlet / JSP / JSTL依赖关系

[英]Tomcat 5.5 Servlet/JSP/JSTL dependencies

I have a problem with Tomcat 5.5 and Java EE webapp libraries. Tomcat 5.5和Java EE webapp库出现问题。 I'm using Gradle for dependency management and I'm using JSP API 2.0, Servlet API 2.4 and JSTL 1.1. 我正在使用Gradle进行依赖项管理,并且正在使用JSP API 2.0,Servlet API 2.4和JSTL 1.1。

I'm getting a org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application 我收到org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

According to http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/ , that means the JSTL implementation is missing. 根据http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/ ,这意味着缺少JSTL实现。

Here is what my web.xml looks like: 这是我的web.xml的样子:

<web-app
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
        http://java.sun.com/xml/ns j2ee/web-app_2_4.xsd"
    version="2.4">


This is how I reference the JSTL libraries: 这就是我引用JSTL库的方式:

 <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 


Corresponding dependencies in Gradle build file: Gradle构建文件中的相应依赖项:

Tomcat 5.5\common\lib

23.09.2002  12:23            45˙386 activation.jar
05.03.2007  17:26           112˙341 commons-el.jar
05.03.2007  17:26         1˙213˙732 jasper-compiler-jdt.jar
05.03.2007  17:26           408˙133 jasper-compiler.jar
05.03.2007  17:26            76˙844 jasper-runtime.jar
05.03.2007  17:26            50˙952 jsp-api.jar
29.08.2005  22:28           358˙085 LOG4J-1.2.12.JAR
12.10.2004  13:20           347˙137 mail-1.3.2.jar
05.03.2007  17:26           163˙490 naming-factory-dbcp.jar
05.03.2007  17:26            31˙963 naming-factory.jar
05.03.2007  17:26            47˙730 naming-resources.jar
05.03.2007  17:26            99˙235 servlet-api.jar


In Tomcat/common/libs, I have these jars: 在Tomcat / common / libs中,我有以下罐子:

 Tomcat 5.5\\common\\lib 23.09.2002 12:23 45˙386 activation.jar 05.03.2007 17:26 112˙341 commons-el.jar 05.03.2007 17:26 1˙213˙732 jasper-compiler-jdt.jar 05.03.2007 17:26 408˙133 jasper-compiler.jar 05.03.2007 17:26 76˙844 jasper-runtime.jar 05.03.2007 17:26 50˙952 jsp-api.jar 29.08.2005 22:28 358˙085 LOG4J-1.2.12.JAR 12.10.2004 13:20 347˙137 mail-1.3.2.jar 05.03.2007 17:26 163˙490 naming-factory-dbcp.jar 05.03.2007 17:26 31˙963 naming-factory.jar 05.03.2007 17:26 47˙730 naming-resources.jar 05.03.2007 17:26 99˙235 servlet-api.jar 


In the built WAR, the only relevant JAR file is jstl-1.1.2.jar 在构建的WAR中,唯一相关的JAR文件是jstl-1.1.2.jar

My guess is you must include both api and impl of jstl in your war file. 我的猜测是您必须在war文件中同时包含api和jstl的impl。 There are few jstl implementations around, for example here or here . 周围的jstl实现很少,例如herehere Unfortunately, i dont know how to force gradle do this for you. 不幸的是,我不知道如何强制gradle为您做到这一点。

I think you could download the c.tld (I have it, if you want, i can upload it anywhere for you) and declare it in web.xml like this: 我认为您可以下载c.tld(如果需要,我可以提供,我可以为您上传它)并在web.xml中声明为:

 <jsp-config>
    <taglib>
        <taglib-uri>/WEB-INF/c.tld</taglib-uri>
        <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>
 </jsp-config>

And in jsp as well: 而且在jsp中:

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
compile "javax.servlet:com.springsource.javax.servlet.jsp.jstl:1.1.2";

此行将为JSTL添加gradle依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM