Tomcat 5.5 Servlet/JSP/JSTL 依赖项
我对 Tomcat 5.5 和 Java EE webapp 库有疑问。我使用 Gradle 进行依赖项管理,并使用 JSP API 2.0、Servlet API 2.4 和 JSTL 1.1。
我收到 org.apache.jasper.JasperException: The Absolute uri: http:// /java.sun.com/jsp/jstl/core 无法在 web.xml 或随此应用程序部署的 jar 文件中解析
根据 http: //www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/,这意味着缺少 JSTL 实现。
我的 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:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Corresponding dependencies in Gradle build file:
providedCompile group: 'javax.servlet', name: 'servlet-api', version: '2.4'
providedCompile group: 'javax.servlet', name: 'jsp-api', version: '2.0'
compile group: 'javax.servlet', name: 'jstl', version: '1.1.+'
In Tomcat/common/libs, I have these jars:
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
I have a problem with Tomcat 5.5 and Java EE webapp libraries. I'm using Gradle for dependency management and I'm using JSP API 2.0, Servlet API 2.4 and 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
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.
Here is what my web.xml looks like:
<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:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Corresponding dependencies in Gradle build file:
providedCompile group: 'javax.servlet', name: 'servlet-api', version: '2.4'
providedCompile group: 'javax.servlet', name: 'jsp-api', version: '2.0'
compile group: 'javax.servlet', name: 'jstl', version: '1.1.+'
In Tomcat/common/libs, I have these jars:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的猜测是你必须在你的 war 文件中包含 jstl 的 both api 和 impl 。周围有很少的 jstl 实现,例如 这里 或 此处 。不幸的是,我不知道如何强制 gradle 为你做这件事。
My guess is you must include both api and impl of jstl in your war file. There are few jstl implementations around, for example here or here . Unfortunately, i dont know how to force gradle do this for you.
我想你可以下载 c.tld (我有它,如果你愿意,我可以为你上传到任何地方)并在 web.xml 中声明它,如下所示:
在 jsp 中也是如此:
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:
And in jsp as well:
此行将为 JSTL 添加 gradle 依赖项。
This line will add the gradle dependency for JSTL.