java无法在嵌入式Jetty服务器中加载JSTL标记库
我正在编写一个在嵌入式Jetty实例中运行的web应用程序
当我试图执行JSTL语句时,我收到以下异常:
org.apache.jasper.JasperException: /index.jsp(1,63) PWC6188: 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
我在类路径上有以下罐子
- 蚂蚁-1.6.5。罐子
- 蚂蚁-1.7.1。罐子
- ant-launcher-1.7.1。罐子
- 核心-3.1.1。罐子
- 码头-6.1.22。罐子
- jetty-util-6.1.22。罐子
- jsp-2.1-6.1.14。罐子
- jsp-api-2.1。罐子
- jstl-1.2。罐子
- servlet-api-2.5-20081211。罐子
- servlet-api-2.5-6.1.14。罐子
- 标准-1.1.2。罐子
我的网络。xml如下所示:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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 h77p://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>test</display-name>
</web-app>
我的代码如下所示:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<h2>Hello World!</h2>
<%= new java.util.Date() %><br/>
${1+2}<br/>
<c:out var="${5+9}"/><br/>
</body>
</html>
我像这样启动了我的嵌入式Jetty服务器:
Server server = new Server(80);
WebAppContext context = new WebAppContext("pig-1.0-SNAPSHOT.war","/");
server.addHandler(context);
server.start();
在过去的两天里,我一直在尝试各种jar文件组合,比如web。xml配置和标记库声明,但没有用
如何让嵌入式Jetty服务器在完全支持JSTL的情况下启动并运行
# 1 楼答案
我也遇到了同样的问题,并发现
http://java.sun.com/jsp/jstl/core
被视为单个系统URI,所有试图定义它的taglib定义都被忽略(但当被引用时,仍然会发生错误)在启动码头之前,我使用了以下方法,现在它可以工作了:
# 2 楼答案
Jetty 8.0是servlet API 3.0,在使用Jetty:run时作为默认版本推送。在该版本的标准中,应该包括JSTL标准,这些标记库不能在webapp类路径中,只能在标准类路径中。然而,8.0.0。M0忘了包括它们
规定7.1.4。v20100610对我有帮助
# 3 楼答案
@Drew 谢谢Drew。它起作用了。我一直在谷歌上搜索这个,最后来到了这里。我的错误是: 我在用
我把它从上面改成了
它开始工作了。我还使用了我删除的jstls依赖项
# 4 楼答案
这是相互冲突的。移除
standard-1.1.2.jar
。你应该只把standard-1.1.2.jar
和jstl-1.1.2.jar
一起使用。自JSTL 1.2以来,标准JAR已经被合并到JSTL JAR中,形成了一个jstl-1.2.jar
文件