java Struts 1 - 我的 Web 应用程序未找到 struts-taglib.jar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2441254/
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
Struts 1 - struts-taglib.jar is not being found by my web application
提问by Yatendra Goel
I am using Struts-1. I have developed a struts-based web application. I am using struts tags in my JSP pages supplied in struts-taglib.jarby inserting the following lines in the JSP file:
我正在使用Struts-1. 我开发了一个基于 struts 的 Web 应用程序。我在 JSP 页面中使用 struts 标签,struts-taglib.jar方法是在 JSP 文件中插入以下几行:
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
Now the application is working fine when I run it on my localsystem but when I deploy it on a server, it shows the following exception:
现在,当我在本地系统上运行该应用程序时,它运行良好,但是当我将它部署到服务器上时,它显示以下异常:
org.apache.jasper.JasperException: The absolute uri: http://struts.apache.org/tags-html cannot be resolved in either web.xml or the jar files deployed with this application
From the above exception, it seems that the application hasn't found the struts-taglib.jarfile.
从上面的异常来看,应用程序似乎还没有找到该struts-taglib.jar文件。
But I have put the struts-taglib.jarin /WEB-INF/libdirectory. Then where is the problem?
但是我已经把struts-taglib.jarin/WEB-INF/lib目录了。那么问题出在哪里呢?
Note: You can also look at Java - Problem in deploying Web Applicationfor more information
注意:您还可以查看Java - 部署 Web 应用程序的问题以获取更多信息
回答by duffymo
You say the JAR does appear in the WEB-INF/lib for the web app; I'll take your word for it and believe you.
您说 JAR 确实出现在 Web 应用程序的 WEB-INF/lib 中;我会相信你的话并相信你。
I would suggest that you open up the struts-taglib.jar, open the .tld for the tag library, and verify that the <uri> value that you find under the <taglib> root matches the uri for the given prefix in your JSPs. I'm guessing that the URI doesn't match, which means the class loader won't be able to find the tag library even if the JAR is in the CLASSPATH.
我建议您打开struts-taglib.jar标记库的 .tld,并验证您在 <taglib> 根下找到的 <uri> 值是否与 JSP 中给定前缀的 uri 匹配。我猜测 URI 不匹配,这意味着即使 JAR 在 CLASSPATH 中,类加载器也无法找到标记库。
It might also indicate whether or not a version change made the URI in your JAR and JSP out of synch.
它还可能表明版本更改是否使 JAR 和 JSP 中的 URI 不同步。
I just downloaded struts-1.3.10-all.zip and looked at the struts-logic.tld contained within. The value of the <uri>tag is http://struts.apache.org/tags-logic, so it looks like you're okay there.
我刚刚下载了 struts-1.3.10-all.zip 并查看了其中包含的 struts-logic.tld 。<uri>标签的值是http://struts.apache.org/tags-logic,所以看起来你在那里没问题。
The .tld files look like they're externalized from the JAR. Look for them under .\src\el\src\main\resources\META-INF\tld, put them in your /WEB-INF, and refer to them explicitly in your web.xml. That should sort you out.
.tld 文件看起来像是从 JAR 外部化的。在 .\src\el\src\main\resources\META-INF\tld 下查找它们,将它们放在您的 /WEB-INF 中,并在您的 web.xml 中明确引用它们。那应该可以解决您的问题。
I don't believe .tld in web.xml is necessary anymore, but if the URI thought doesn't pan out you can try adding something similar to this example from "JSTL In Action" to your web.xml (modified accordingly):
我不相信 web.xml 中的 .tld 是必要的,但是如果 URI 想法没有成功,您可以尝试将类似于此示例的内容从“JSTL In Action”添加到您的 web.xml(相应修改):
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
It could be because Struts 1.0 is rather old at this point. Packaging the .tld in the JAR of the taglib became a common practice after Struts 1.0 was developed.
这可能是因为此时 Struts 1.0 相当老了。在 Struts 1.0 开发之后,将 .tld 打包在 taglib 的 JAR 中成为一种普遍做法。
回答by Tom
Is /WEB-INF/libin your classpath ?
是/WEB-INF/lib在你的classpath?
回答by kukudas
After deploying it is the jar file actually in /WEB-INF/lib ? If not will putting it by hand resolve the problem?
部署后它实际上是 /WEB-INF/lib 中的 jar 文件?如果没有,手动放置会解决问题吗?
回答by lzap
Doublecheck your URI and the URI in the TLD file from struts-taglib.jar.
仔细检查您的 URI 和来自 struts-taglib.jar 的 TLD 文件中的 URI。
Please note URI has been changed recently: http://wiki.apache.org/struts/StrutsUpgradeNotes12to13
请注意 URI 最近已更改:http: //wiki.apache.org/struts/StrutsUpgradeNotes12to13
回答by Nguyen Tri Tin
Make sure that your struts-taglib-1.3.10.jar is directly under /WEB-INF/lib, not in any sub-folder like /WEB-INF/lib/struts
确保你的 struts-taglib-1.3.10.jar 直接在 /WEB-INF/lib 下,而不是在任何像 /WEB-INF/lib/struts 这样的子文件夹中

