<c:out/>未知标签

2022-01-18 00:00:00 tags java jsp eclipse jstl

当我包含以下行时,为什么我在左侧的 Eclipse 中收到错误提示消息.

Why I get error tip message in eclipse on left when I include the following line.

<c:out value=${variable}/>

我收到错误未知标签(c:out)"

I get the error "Unknown tag(c:out)"

我也包括在上面

<%@ page isELIgnored ="false" %> 

我需要包含一个 jstl 吗?

Is there a jstl I need to include?

推荐答案

您显然是在使用不支持 JSTL 的 servlet 容器进行开发,例如 Tomcat.在这种情况下,您需要下载 jstl-1.2.jar 并放入您的 webapp 的 /WEB-INF/lib 文件夹中.不需要其他更改是必要的,也不要像一些糟糕的在线教程所建议的那样提取 JAR 文件和/或在 /WEB-INF 文件夹中乱扔 TLD 文件.

You're apparently developing with a servlet container which does not support JSTL out the box, such as Tomcat. In that case, you need to download jstl-1.2.jar and drop in /WEB-INF/lib folder of your webapp. No other changes are necessary, also not extracting the JAR file and/or littering the /WEB-INF folder with loose TLD files as some poor online tutorials suggest.

将 JAR 文件放入类路径(/WEB-INF/lib 文件夹是 webapp 的运行时类路径的一部分)后,您应该能够通过将根据 它的文档:

After having dropped the JAR file in the classpath (the /WEB-INF/lib folder is part of the webapp's runtime classpath), you should be able to reference the JSTL core taglib by putting the following line in top of your JSP as per its documentation:

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

JSTL 1.2 要求 web.xml 中至少有 Servlet 2.4 声明.因此,请确保您的 web.xml 具有正确的根声明,最好是 servlet 容器支持的最高支持版本(Tomcat 7 是 Servlet 3.0,Tomcat 6 是 Servlet 2.5,Tomcat 5.5 是 Servlet 2.4).

JSTL 1.2 requires a minimum of Servlet 2.4 declaration in web.xml. So make sure that your web.xml has the proper root declaration, preferably the highest supported version as supported by your servlet container (Tomcat 7 is Servlet 3.0, Tomcat 6 is Servlet 2.5 and Tomcat 5.5 is Servlet 2.4).

  • 我们的 JSTL 标签 wiki 页面(您可以通过将鼠标放在 [jstl] 标签,您自己在问题上添加并单击弹出框上的 info 链接)
  • Our JSTL tag wiki page (you can get to this page by putting your mouse above the [jstl] tag which you put on the question yourself and clicking the info link on the popbox)

相关文章