Eclipse“找不到标签库描述符” 用于自定义标签(不是 JSTL!)

发布于 2024-07-30 08:45:01 字数 583 浏览 5 评论 0原文

我有一个 Java EE 项目,它使用 Ant 构建得很好,完美地部署到 JBoss,并且运行没有任何问题。 该项目包括一些自定义标签库(不是JSTL!),它们也是工作没有任何困难。

问题出在 Eclipse IDE (Ganymede) 上:在每个使用自定义标签的 JSP 文件中,JSP 解析器都会将 taglib include 行标记为以下错误:

Cannot find the tag library detector for (example).tld

这也导致每次使用选项卡库都会被标记为错误,并且由于 IDE 没有它们的定义,因此无法检查标记参数等。

我们完美工作的 JSP 文件是一片海红色错误,我的眼睛开始灼烧。

我怎样才能简单地告诉 Eclipse,“您正在寻找的标签库描述符是“src/web/WEB-INF/(example)-taglib/(example).tld”?

我已经在 Eclipse 支持上问过这个问题论坛,没有任何有用的结果。

I have a Java EE project which build fine with Ant, deploys perfectly to JBoss, and runs without any trouble. This project includes a few custom tag libraries (which is not JSTL!), which are also working without any difficulties.

The problem is with the Eclipse IDE (Ganymede): in every single JSP file which uses our custom tags, the JSP parser flags the taglib include line with with this error:

Cannot find the tag library descriptor for (example).tld

This also causes every use of the tab library to be flagged as an error, and since the IDE doesn't have their definition, it can't check tag parameters, etc.

Our perfectly-working JSP files are a sea of red errors, and my eyes are beginning to burn.

How can I simply tell Eclipse, "The tag library descriptor you are looking for is "src/web/WEB-INF/(example)-taglib/(example).tld"?

I've already asked this question on the Eclipse support forums, with no helpful results.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(22

把昨日还给我 2024-08-06 08:45:02

事实证明,原因是 Eclipse 根本不认为该项目实际上是一个 Java EE 项目; 这是一个来自 3.1 的旧项目,而我们现在使用的 Eclipse 3.5 需要在项目配置文件中设置几个“性质”。

<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>InCode.inCodeNature</nature>
    <nature>org.eclipse.dltk.javascript.core.nature</nature>
    <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
</natures>

我能够通过创建一个新的“动态 Web 项目”来找到原因,该项目可以正确读取其 JSP 文件,并与旧项目的配置进行比较。

我找到添加这些的唯一方法是编辑 .project 文件,但重新打开项目后,一切都神奇地工作了。 上面 pribeiro 引用的设置不是必需的,因为项目已经符合默认设置。

pribeiro 和 nitind 的答案都给了我启动搜索的想法,谢谢。

有没有办法在用户界面中编辑这些“性质”?

It turns out that the cause was that this project wasn't being considered by Eclipse to actually be a Java EE project at all; it was an old project from 3.1, and the Eclipse 3.5 we are using now requires several "natures" to be set in the project configuration file.

<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>InCode.inCodeNature</nature>
    <nature>org.eclipse.dltk.javascript.core.nature</nature>
    <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
</natures>

I was able to find the cause by creating a new "Dynamic Web Project" which properly read its JSP files, and diffing against the config of the older project.

The only way I could find to add these was by editing the .project file, but after re-opening the project, everything magically worked. The settings referenced by pribeiro, above, weren't necessary since the project already conformed to the default settings.

Both pribeiro and nitind's answers gave me ideas to jumpstart my search, thanks.

Is there a way of editing these "natures" from within the UI?

哥,最终变帅啦 2024-08-06 08:45:02

遇到了同样的问题,我正在使用 maven,所以我将其添加到我的 web 项目中的 pom 中:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version> <!-- just used the latest version, make sure you use the one you need -->
    <scope>provided</scope>
</dependency>

这解决了问题,并且我使用了“provided”范围,因为像 OP 一样,一切都已经在 J​​Boss 中运行。

这是我找到解决方案的地方: http://alfredjava.wordpress.com/2008/12/ 22/jstl-connot-resolved/

Ran into the same problem, I'm using maven so I added this to the pom in my web project:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version> <!-- just used the latest version, make sure you use the one you need -->
    <scope>provided</scope>
</dependency>

This fixed the problem and I used "provided" scope because like the OP, everything was already working in JBoss.

Here's where I found the solution: http://alfredjava.wordpress.com/2008/12/22/jstl-connot-resolved/

來不及說愛妳 2024-08-06 08:45:02

当我尝试将 JSTL 核心库包含在我的 JSP 中时:

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

我在 Eclipse (Indigo) 中收到以下错误:

Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

我转到项目属性 -> Targeted Runtimes,然后检查我正在使用的服务器 (Geronimo 3.0)。 大多数人会使用 Tomcat。 这解决了我的问题。 希望能帮助到你!

When I tried to include the JSTL Core Library in my JSP:

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

I got the following error in Eclipse (Indigo):

Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

I went to the Project Properties -> Targeted Runtimes, and then checked the Server I was using (Geronimo 3.0). Most people would be using Tomcat. This solved my problem. Hope it helps!

水染的天色ゝ 2024-08-06 08:45:02

我今天解决了这个问题。

  • 将输出目录更改为 WEB-INF/classes 文件夹。 (项目/属性/Java 构建路径,默认输出文件夹)
  • 分配模块依赖项。 (项目/属性/Java EE 模块依赖项)它们将被复制到 WEB-INF/lib 文件夹,Eclipse 也会在其中查找标签库定义。

我希望它有帮助。

I fixed this problem today.

  • Change your output directory to your WEB-INF/classes folder. (Project/Properties/Java Build Path, Default output folder)
  • Assigne the module dependencies. (Project/Properties/Java EE Module Dependencies) they will be copied to the WEB-INF/lib folder where Eclipse looks for the tag lib definitions too.

I hope it helps.

菊凝晚露 2024-08-06 08:45:02

很大程度上取决于它是什么类型的项目。 WTP 的 JSP 支持要么期望 JSP 文件位于 WEB-INF 文件夹的父文件夹(src/web,然后将其视为“/”以查找 TLD)下,要么将项目元数据设置为帮助它知道根在哪里(通过部署程序集在动态 Web 项目中为您完成)。 您如何引用 TLD 文件?JSP 文件位于何处?

也许我错过了 Eclipse 论坛的原始帖子; 我看到的那个是在这个之后一整天发布的。

A lot depends on what kind of project it is. WTP's JSP support either expects the JSP files to be under the same folder that's the parent of the WEB-INF folder (src/web, which it will then treat as "/" to find TLDs), or to have project metadata set up to help it know where that root is (done for you in a Dynamic Web Project through Deployment Assembly). How are you referring to the TLD file, and where is the JSP file located?

And maybe I missed the original post to the Eclipse forums; the one I saw was posted a full day after this one.

放我走吧 2024-08-06 08:45:02

检查F:\apache-tomcat-7.0.21\webapps\examples\WEB-INF\lib中的两个库:

  1. jstl.jar
  2. standard.jar

Check the two libraries in F:\apache-tomcat-7.0.21\webapps\examples\WEB-INF\lib:

  1. jstl.jar
  2. standard.jar
强辩 2024-08-06 08:45:02

我遇到了同样的问题。
这就是我为解决该问题所做的事情。

  1. 选择项目并右键单击。
  2. 单击属性。
  3. 单击库选项卡。
  4. 单击“添加罐子”。
  5. 为您的错误添加相关的 jar。

I faced same problem.
This is what I did to resolve the issue.

  1. Select Project and right click.
  2. Click on properties.
  3. Click on libraries tab.
  4. Click on 'Add Jars'.
  5. Add relevant jar for your error.
仄言 2024-08-06 08:45:02

您只需转到“构建路径”->“构建路径”即可。 添加库并为要添加的库类型选择“服务器运行时”。 单击下一步并选择要添加到类路径中的服务器运行时,如果 jstl.jar 和 standard.jar 位于服务器的类路径中,问题就会消失。

You can simply go to Build Path -> Add Libraries and for the library type to add select "Server Runtime." Click Next and select a server runtime to add to the classpath and the problem goes away if jstl.jar and standard.jar are in your server's classpath.

生生漫 2024-08-06 08:45:02

我正在使用 Spring STS 插件和 Spring webmvc 模板项目。 我必须先安装 Maven m2e 插件: http://www.eclipse.org/m2e/

然后清理项目。 在项目 -> 下 干净...

I'm using Spring STS plugin and a Spring webmvc template project. I had to install the Maven m2e plugin first: http://www.eclipse.org/m2e/

And then clean the project. Under Project -> Clean...

泛泛之交 2024-08-06 08:45:02

如果您的 tld 位于类路径上(通常位于 WEB-INF 目录下),则以下两个提示应该可以解决问题(无论您的环境设置如何):

  1. 确保 TLD 和 jsp 页面 taglib 指令中的 uri 相匹配。 TLD 的 元素是标记库的唯一名称。

  2. 如果 tld 没有 元素,容器将尝试使用 taglib 指令中的 uri 属性作为实际 TLD 的路径。 例如,我可以在 WEB-INF 文件夹中有一个自定义 tld 文件,并使用该 tld 的路径作为 JSP 中的 uri 值。 但是,这是一种不好的做法,应该避免,因为路径将被硬编码。

If your tld's are on the classpath, typically under the WEB-INF directory, the following two tips should resolve the issue (irrespective of your environment setup):

  1. Ensure that the <uri> in the TLD and the uri in the taglib directive of your jsp pages match. The <uri> element of the tld is a unique name for the tag library.

  2. If the tld does not have a <uri> element, the Container will attempt to use the uri attribute in the taglib directive as a path to the actual TLD. for e.g. I could have a custom tld file in my WEB-INF folder and use the path to the this tld as the uri value in my JSP. However, this is a bad practice and should be avoided since the paths would then be hardcoded.

三生一梦 2024-08-06 08:45:02

我在 MyEclipse 和 Eclipse 6.6.0 上也遇到了同样的问题。 中将 uri 值标红

它在每个<%@ taglib prefix="s" uri="/struts-tags"%>
我通过转到“Project/MyEclipse/Web/Tag Libraries”并将 Struts 1.2 Tiles 标签的默认 TLD 前缀设置为“s”来修复此问题。 我还必须在“Project/MyEclipse/Web/Configure workspace settings.../Tag Libraries”下执行相同的操作。

I had the same problem with MyEclipse and Eclipse 6.6.0. It red lined the uri value in every

<%@ taglib prefix="s" uri="/struts-tags"%>.
I fixed it by going to 'Project/MyEclipse/Web/Tag Libraries' and setting the Default TLD Prefix for Struts 1.2 Tiles Tags to 's'. I also had to do the same under 'Project/MyEclipse/Web/Configure workspace settings.../Tag Libraries'.

淡莣 2024-08-06 08:45:02

我对 STS(springtool 源套件)也有同样的问题。

在 STS 下,右键单击项目,选择“属性”、“项目 Facets”,然后在窗口右侧单击“运行时”选项卡,选中“VMware vFabric tc Server (...)”,然后单击“应用”,工作区刷新后应该就可以了。

I had the same problem with STS (springtool source suite).

Under STS, right click on the project, than "Properties", "Project Facets", than on the right of the window click on the "runtime" tab, and check "VMware vFabric tc Server (...)", and click "Apply" and it should be OK after the workspace refresh.

少钕鈤記 2024-08-06 08:45:02

好吧,你需要理解总是有两件事:API 和实现(注意以下代码的 gradle 格式)

compile group:'javax.servlet.jsp.jstl', name:'javax.servlet.jsp。 jstl-api', version:'1.2.1'

编译组:'org.glassfish.web', name:'javax.servlet.jsp.jstl',version:'1.2.1'< /code>

所以如果你使用的是没有 jstl 支持的 servlet 容器,那么它当然不会提供这两个容器,我犯的一个错误是我只放置了第一个,但是如果你使用的是全栈应用程序服务器,即 glassfish,那么 glassfish 将把它们都包含在里面。

well you need to understand there are always two things the API and the implementation (mind the gradle format of the following code)

compile group:'javax.servlet.jsp.jstl', name:'javax.servlet.jsp.jstl-api', version:'1.2.1'

compile group:'org.glassfish.web', name:'javax.servlet.jsp.jstl',version:'1.2.1'

so If you're using a servlet container with no jstl support then of course it will not provide both of them, a mistake which I made is that I only put the first one, but if you're using full stack application server i.e glassfish then glassfish will have both of them already inside.

尬尬 2024-08-06 08:45:02

对我来说,每当我尝试使用新版本的 eclipse 时就会出现此错误。 显然,新的 Eclipse 重置了 M2_REPO 变量,并且我在 Marker 视图中收到了所有标记库错误(有时带有 ejb 验证错误)。

更新 M2_REPO 变量以指向实际的 Maven 存储库位置后,需要 2-3 Project -> 干净的迭代让一切正常运转。

有时,除了此标记库错误之外,还会出现一些 xml 验证错误(ejb)。 手动更新相应的 XML 文件,启动 *.xsd 文件查找并解决 xml 验证错误。 此后,标签库错误也消失了。

For me, this error occurs whenever I try to use a new version of eclipse. Apparently, the new eclipse resets the M2_REPO variable and I get all the tag library error in the Marker view (sometimes with ejb validation errors).

After updating M2_REPO variable to point to actual maven repository location, it takes 2-3 Project -> Clean iterations to get everything working.

And sometimes, there are some xml validation errors(ejb) along with this tag library errors. Manually updating the corresponding XML file, initiates a *.xsd file lookup and the xml validations errors are resolved. Post this, the tag library errors also vanish.

泅渡 2024-08-06 08:45:02

另一方面,如果您只处理 java 源代码,并且从正在运行的大型项目中未接触过的内容中得到这些错误,则可以在 Eclipse 中关闭验证。 设置位于 Preferences->Web->JSP Files->Validation 下

On the other hand, if you are only working on java source and are getting these errors from stuff you don't touch in a large project that is working, you can just turn off the validations in Eclipse. The settings are under Preferences->Web->JSP Files->Validation

拒绝两难 2024-08-06 08:45:02

我在使用 Tomcat 6.0 和 Eclipse 时遇到了同样的问题,我尝试了我朋友建议的一些方法,它对我有用。
我提出的问题和评论的回复的链接可以在这里找到:

JSTL Tomcat 6.0 找不到标记库描述符错误

请告诉我这是否解决了您的“找不到标记库描述符”问题。

I was having the same problem using Tomcat 6.0 and Eclipse and I tried out something which my friend suggested and it worked for me.
The link for the question I asked and my reply commented can be found here:

JSTL Tomcat 6.0 Cannot find the taglib descriptor Error

Let me know if this solves your "Cannot find the taglibrary descriptor" problem.

上课铃就是安魂曲 2024-08-06 08:45:02

此错误可能由多个不同的来源引起。 当 Eclipse 未实现 TLD 文档中设置的 JSP 规范版本时,会发生一种情况(此问题的其他答案中未提及)。 Eclipse 版本在实施更新的 servlet 和 JSP 规范方面通常会落后一年。 例如,请参阅此 Eclipse 错误

在这种情况下,您的 Web 应用程序可能在最新版本的 Tomcat 中运行良好,但 Eclipse 可能仍会抱怨缺少 TLD。 短期解决方案(除了忽略 Eclipse 中的错误之外)是将 JSP 版本降低到您的 Eclipse 版本支持的版本。

另外,请记住您正在实施的 TLD 版本。 标签名称从 v1.1 到 v2.0 略有变化(即 info 现在是 taglib 上的 description 并且不是有效元素在 tag 下,许多元素名称现在包含连字符)。 Eclipse 不容忍拼写错误的 TLD 标记名称。

TLD 2.0(jsp 版本 2.0)参考

TLD 2.1(jsp 版本 2.3)参考

This error can arise from several different sources. One case (not mentioned in other answers to this question) occurs when Eclipse does not implement the version of the JSP specification set in the TLD document. Eclipse releases typically lag behind up to a year in implementing newer servlet and JSP specifications. See this Eclipse bug for example.

In this case, your web application may run fine in the latest version of Tomcat, but Eclipse may still complain about a missing TLD. The short term solution (short of ignoring the error in Eclipse) is to bump down the JSP version to the one that your version of Eclipse supports.

Also, keep in mind the TLD version you are implementing. The tag names have changed slightly from v1.1 to v2.0 (i.e., info is now description on taglib and is not a valid element under tag, many of the element names now contain a hyphen). Eclipse has no tolerance for misspelled TLD tag names.

TLD 2.0 (jsp-version 2.0) Reference

TLD 2.1 (jsp-version 2.3) Reference

早乙女 2024-08-06 08:45:02

将 jstl.jar 替换为 jstl1.2.jar 解决了 tomcat 7.0 的问题

replace jstl.jar to jstl1.2.jar resolved the issue for tomcat 7.0

汹涌人海 2024-08-06 08:45:02

我也面临同样的问题。 确保 Eclipse 和 Tomcat 工作目录(即 \webapps\examples\WEB-INF\liblib 文件夹)中具有相同版本的 JSTL。

I also faced the same problem. Make sure you have same versions of JSTL in Eclipse and in the Tomcat work directory, i.e in \webapps\examples\WEB-INF\lib and in lib folder.

╄→承喏 2024-08-06 08:45:01

在 Eclipse Helios 中,项目属性中的“Java EE 模块依赖项”已替换为“部署程序集”。

因此,为了使用 Eclipse Helios 解决这个问题,我的方法如下:

  • 在包资源管理器中右键单击该项目,然后选择“导入...”
  • 接受默认选择“文件系统”,然后按“下一步”
  • 按“浏览” " 在 From 目录行中,转到您的 tomcat 安装并找到文件 webapps/examples/WEB-INF/lib (我有 tomcat 6,其他版本的 Tomcat 可能具有路径 webapps/jsp-examples/WEB-INF/lib )。 进入路径后,按“确定”。
  • 单击 jstl.jar 和 standard.jar 旁边的复选框以激活复选框
  • 在“进入文件夹”行上,单击“浏览”并选择库文件夹。 我在项目中使用/lib。
  • 单击“完成”
  • 在 Package Explorer 视图中右键单击该项目,然后选择属性(或按 Alt + Enter)
  • 单击“Java Build Path” 单击
  • “Add Jar”,单击您的项目、文件夹 lib,选择 jstl.jar,然后按OK
  • 单击“Add Jar”,单击您的项目、文件夹 lib,选择 standard.jar,按 OK
  • 按 OK 关闭属性对话框
  • 单击 Problems 视图并选择消息“Classpath entry .../jstl.jar will not可能会导致导出或发布运行时 ClassNotFoundExceptions。”
  • 右键单击它并选择“快速修复”。
  • 接受默认的“将关联的原始类路径条目标记为发布/导出依赖项”,然后按“完成”。
  • 对standard.jar 执行相同操作,

这可以解决问题,但如果您想检查“部署程序集”中发生了什么,请再次打开项目属性,选择“部署程序集”,您将看到standard.jar 和jstl。 jar 已添加到 WEB-INF/lib 文件夹中。

In Eclipse Helios "Java EE Module Dependencies" in the project properties has been replaced with "Deployment Assembly".

So for solving this problem with Eclipse Helios, the way I did it is the following:

  • Right click on the project in package explorer and choose "Import..."
  • Accept the default selection "File System" and press "Next"
  • Press "Browse" in the From directory line, go to your tomcat installation and locate the file webapps/examples/WEB-INF/lib (I have tomcat 6, other versions of Tomcat may have the path webapps/jsp-examples/WEB-INF/lib). Once in the path press OK.
  • Click besides jstl.jar and standard.jar to activate the check boxes
  • On the line Into folder click on Browse and choose the library folder. I use /lib inside the project.
  • Click "Finish"
  • Right click on the project in Package Explorer view and choose properties (or press Alt + Enter)
  • Click on "Java Build Path"
  • Click "Add Jar", click on your project, folder lib, select jstl.jar, press OK
  • Click "Add Jar", click on your project, folder lib, select standard.jar, press OK
  • Press OK to dismiss the properties dialog
  • Click on the Problems view and select the message "Classpath entry .../jstl.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.".
  • Right click on it and select "Quick Fix".
  • Accept the default "Mark the associated raw classpath entry as a publish/export dependency" and press Finish.
  • Do the same for standard.jar

This solves the problem, but if you want to check what has happened in "Deployment Assembly", open the project properties again, select "Deployment Assembly" and you'll see that standard.jar and jstl.jar have been added to WEB-INF/lib folder.

浅忆流年 2024-08-06 08:45:01

这是我的问题以及我如何修复它...

我已经完成了上面每个人提到的所有操作等,但仍然收到此错误。 原来我使用的是 http://java.sun.com/jsp/jstl/fmthttp://java.sun.com/jsp/jstl/core< 的 uri /code> 这是不正确的。

尝试将上面的 uri 切换为:

http://java.sun.com/jstl/fmt
http://java.sun.com/jstl/core

另外,请确保类路径中引用了正确的 jar。

This was my problem and how I fixed it...

I had done everything everyone had mentioned above etc. but was still getting this error. Turns out I was using the uri's of http://java.sun.com/jsp/jstl/fmt and http://java.sun.com/jsp/jstl/core which were incorrect.

Try switching the uris from above to:

http://java.sun.com/jstl/fmt
http://java.sun.com/jstl/core

Also, make sure you have the correct jars referenced in your class path.

Hello爱情风 2024-08-06 08:45:01

我遇到了同样的问题,条纹 taglib uri 显示为未找到。 我正在使用 Indigo 和 Maven,当我检查 Properties->Java Build Path->Order & 导出选项卡 我发现(在新项目结帐时)“Maven 依赖项”复选框由于某种原因未选中。 只需选中该框并执行 Maven 全新安装即可清除所有错误。

我想知道为什么 Eclipse 不认为我希望我的 Maven 依赖项出现在构建路径中......

I had the same problem with a stripes taglib uri showing as not found. I was using Indigo and Maven and when I checked Properties->Java Build Path->Order & Export Tab I found (on a fresh project checkout) that the "Maven Dependencies" checkbox was unchecked for some reason. Simply checking that box and doing a Maven clean install cleared all the errors.

I wonder why Eclipse doesn't assume I want my Maven dependencies in the build path...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文