Struts 1 - 我的 Web 应用程序未找到 struts-taglib.jar
我正在使用 Struts-1
。我开发了一个基于struts 的Web 应用程序。我通过在 JSP 文件中插入以下行,在 struts-taglib.jar
中提供的 JSP 页面中使用 struts 标签:
<%@ 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" %>
现在,当我在本地系统上运行应用程序时,但当我部署时,应用程序工作正常在服务器上,它显示以下异常:
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
从上面的异常来看,应用程序似乎没有找到 struts-taglib.jar
文件。
但我已将 struts-taglib.jar
放在 /WEB-INF/lib
目录中。那么问题出在哪里呢?
注意:您还可以查看 Java - 问题在部署 Web 应用程序中了解更多信息
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.jar
by inserting the following lines in the JSP file:
<%@ 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.jar
file.
But I have put the struts-taglib.jar
in /WEB-INF/lib
directory. Then where is the problem?
Note: You can also look at Java - Problem in deploying Web Application for more information
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你说 JAR 确实出现在 Web 应用程序的 WEB-INF/lib 中;我会相信你的话并相信你。
我建议您打开是否正确。您在下找到的值root 与 JSP 中给定前缀的 uri 匹配。我猜测 URI 不匹配,这意味着即使 JAR 位于 CLASSPATH 中,类加载器也无法找到标记库。
struts-taglib.jar
,打开标签库的 .tld,并验证它还可能表明版本更改是否导致 JAR 和 JSP 中的 URI 不同步。
我刚刚下载了 struts-1.3.10-all.zip 并查看了其中包含的 struts-logic.tld 。
标记的值是http://struts.apache.org/tags-logic
,所以看起来没问题。.tld 文件看起来像是从 JAR 外部化的。在 .\src\el\src\main\resources\META-INF\tld 下查找它们,将它们放入 /WEB-INF 中,并在 web.xml 中显式引用它们。那应该可以解决你的问题。
我不相信 web.xml 中的 .tld 是必要的,但如果 URI 想法不成功,您可以尝试将“JSTL In Action”中类似的内容添加到您的 web.xml 中(进行相应修改):
可能是因为 Struts 1.0 目前已经相当老了。 Struts 1.0 开发后,将 .tld 打包在 taglib 的 JAR 中成为一种常见的做法。
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.
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.It might also indicate whether or not a version change made the URI in your JAR and JSP out of synch.
I just downloaded struts-1.3.10-all.zip and looked at the struts-logic.tld contained within. The value of the
<uri>
tag ishttp://struts.apache.org/tags-logic
, so it looks like you're okay there.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.
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):
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.
/WEB-INF/lib
在你的类路径中吗?Is
/WEB-INF/lib
in your classpath ?部署后,jar 文件实际上在 /WEB-INF/lib 中吗?如果不是的话,用手把它解决可以解决问题吗?
After deploying it is the jar file actually in /WEB-INF/lib ? If not will putting it by hand resolve the problem?
仔细检查您的 URI 和 struts-taglib.jar 中 TLD 文件中的 URI。
请注意 URI 最近已更改:http://wiki.apache.org/struts/StrutsUpgradeNotes12to13
Doublecheck your URI and the URI in the TLD file from struts-taglib.jar.
Please note URI has been changed recently: http://wiki.apache.org/struts/StrutsUpgradeNotes12to13
确保您的 struts-taglib-1.3.10.jar 直接位于 /WEB-INF/lib 下,而不是位于 /WEB-INF/lib/struts 等任何子文件夹中
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