gpt4 book ai didi

java - 用于 jSTL 的 web.xml

转载 作者:搜寻专家 更新时间:2023-10-31 19:58:31 25 4
gpt4 key购买 nike

我尝试用 jSTL 编写代码。异常(exception)是

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

我正在使用 eclipse 。我添加了 jstl.jarstandard.jar . web.xml 我应该给什么现在?我不知道该在<taglib> 中给出什么.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<c:forEach var = "userName" items = "${name}">
<tr>
<td>${userName}</td>

</tr>
</c:forEach>

</body>
</html>

最佳答案

如果您下载了具有不同 URI 的古老 JSTL 1.0,或者您将 JAR 放在错误的位置(即不在 /WEB-INF/lib 或 webapp 的任何地方),就会发生这种情况运行时类路径)。

确保您下载了正确的版本并将 JAR 放入 /WEB-INF/lib。对于 web.xml 声明为 Servlet 2.5 的 Web 应用程序,您只需下载 JSTL 1.2 as jstl-1.2.jar .对于 Servlet 2.4 web 应用程序,您需要下载 JSTL 1.1 as jstl.jar and standard.jar .

您不需要提取 JAR。您也不需要像一些糟糕的在线教程所建议的那样修改 web.xml。只需将 JAR 放到运行时类路径中,在 JSP 中声明标签库即可。

关于java - 用于 jSTL 的 web.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4437768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com