Eclipse“找不到标签库描述符” 用于自定义标签(不是 JSTL!)
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(22)
事实证明,原因是 Eclipse 根本不认为该项目实际上是一个 Java EE 项目; 这是一个来自 3.1 的旧项目,而我们现在使用的 Eclipse 3.5 需要在项目配置文件中设置几个“性质”。
我能够通过创建一个新的“动态 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.
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?
遇到了同样的问题,我正在使用 maven,所以我将其添加到我的 web 项目中的 pom 中:
这解决了问题,并且我使用了“provided”范围,因为像 OP 一样,一切都已经在 JBoss 中运行。
这是我找到解决方案的地方: 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:
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/
当我尝试将 JSTL 核心库包含在我的 JSP 中时:
我在 Eclipse (Indigo) 中收到以下错误:
我转到项目属性 -> Targeted Runtimes,然后检查我正在使用的服务器 (Geronimo 3.0)。 大多数人会使用 Tomcat。 这解决了我的问题。 希望能帮助到你!
When I tried to include the JSTL Core Library in my JSP:
I got the following error in Eclipse (Indigo):
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!
我今天解决了这个问题。
我希望它有帮助。
I fixed this problem today.
I hope it helps.
很大程度上取决于它是什么类型的项目。 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.
检查
F:\apache-tomcat-7.0.21\webapps\examples\WEB-INF\lib
中的两个库:Check the two libraries in
F:\apache-tomcat-7.0.21\webapps\examples\WEB-INF\lib
:我遇到了同样的问题。
这就是我为解决该问题所做的事情。
I faced same problem.
This is what I did to resolve the issue.
您只需转到“构建路径”->“构建路径”即可。 添加库并为要添加的库类型选择“服务器运行时”。 单击下一步并选择要添加到类路径中的服务器运行时,如果 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.
我正在使用 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...
如果您的 tld 位于类路径上(通常位于 WEB-INF 目录下),则以下两个提示应该可以解决问题(无论您的环境设置如何):
确保
TLD 和 jsp 页面 taglib 指令中的 uri 相匹配。 TLD 的
元素是标记库的唯一名称。如果 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):
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.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.我在 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'.
我对 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.
好吧,你需要理解总是有两件事: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.
对我来说,每当我尝试使用新版本的 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 theMarker
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.
另一方面,如果您只处理 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
我在使用 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.
此错误可能由多个不同的来源引起。 当 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 nowdescription
ontaglib
and is not a valid element undertag
, 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
将 jstl.jar 替换为 jstl1.2.jar 解决了 tomcat 7.0 的问题
replace jstl.jar to jstl1.2.jar resolved the issue for tomcat 7.0
我也面临同样的问题。 确保 Eclipse 和 Tomcat 工作目录(即
\webapps\examples\WEB-INF\lib
和lib
文件夹)中具有相同版本的 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 inlib
folder.在 Eclipse Helios 中,项目属性中的“Java EE 模块依赖项”已替换为“部署程序集”。
因此,为了使用 Eclipse Helios 解决这个问题,我的方法如下:
这可以解决问题,但如果您想检查“部署程序集”中发生了什么,请再次打开项目属性,选择“部署程序集”,您将看到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:
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.
这是我的问题以及我如何修复它...
我已经完成了上面每个人提到的所有操作等,但仍然收到此错误。 原来我使用的是
http://java.sun.com/jsp/jstl/fmt
和http://java.sun.com/jsp/jstl/core< 的 uri /code> 这是不正确的。
尝试将上面的 uri 切换为:
另外,请确保类路径中引用了正确的 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
andhttp://java.sun.com/jsp/jstl/core
which were incorrect.Try switching the uris from above to:
Also, make sure you have the correct jars referenced in your class path.
我遇到了同样的问题,条纹 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...