java jstl 的 web.xml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4437768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 06:22:31  来源:igfitidea点击:

web.xml for jstl

javajspjstl

提问by Sumithra

I tried codes with jstl. The exception is

我用jstl试过代码。例外是

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/corecannot be resolved in either web.xml or the jar files deployed with this application

org.apache.jasper.JasperException:绝对 uri:http: //java.sun.com/jsp/jstl/core无法在 web.xml 或使用此应用程序部署的 jar 文件中解析

I am using eclipse. I added jstl.jarand standard.jar. What should I give in web.xmlnow? I don't know what to give in <taglib>.

我正在使用日食。我加了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>

回答by BalusC

This can happen if you either downloaded the ancient JSTL 1.0 which has a different URI, or you placed the JAR's in the wrong place (i.e. not in /WEB-INF/libor anywhere in webapp's runtime classpath).

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

Ensure that you download the right version and put the JAR(s) in /WEB-INF/lib. For a webapplication whose web.xmlis declared as Servlet 2.5, you need to download just JSTL 1.2 as jstl-1.2.jar. For a Servlet 2.4 webapplication, you need to download JSTL 1.1 as jstl.jar and standard.jar.

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

You don't need to extract the JAR's. You also don't need to modify the web.xmlas some poor online tutorials suggest. Just drop JAR(s) in runtime classpath, declare the taglib in JSP and that's it.

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

回答by Tushar Sagar

There is no need to make an entry of jstl.jar or standard.jar inside web.xml if the jars are kept in the lib directory inside WEB-INF. The container by default looks into the lib directory of WEB-INF

如果 jar 文件保存在 WEB-INF 中的 lib 目录中,则无需在 web.xml 中创建 jstl.jar 或 standard.jar 条目。容器默认查看WEB-INF的lib目录

回答by Dave G

You shouldn't have to add the taglib elements to web.xml. The standard & jstl jars are interrogated via the service mechanism in the container.

您不必将 taglib 元素添加到 web.xml。标准和 jstl jars 通过容器中的服务机制进行查询。

Make sure the jars are exported with the web-app and located under WEB-INF/lib and you should be fine.

确保 jars 与 web-app 一起导出并位于 WEB-INF/lib 下,你应该没问题。