我的Web应用程序找不到Struts 1 - struts-taglib.jar [英] Struts 1 - struts-taglib.jar is not being found by my web application

查看:168
本文介绍了我的Web应用程序找不到Struts 1 - struts-taglib.jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Struts-1 。我开发了一个基于struts的Web应用程序。我在JSP文件中插入以下行,在 struts-taglib.jar 中提供的JSP页面中使用struts标记:

 <%@ taglib prefix =htmluri =http://struts.apache.org/tags-html%> 
<%@ taglib prefix =logicuri =http://struts.apache.org/tags-logic%>
<%@ taglib prefix =beanuri =http://struts.apache.org/tags-bean%>

现在,当我在我的本地系统上运行它时,应用程序运行正常,但是当我在服务器上部署它时,它显示以下异常:

  org.apache.jasper.JasperException:绝对uri:http://struts.apache无法在web.xml或使用此应用程序部署的jar文件中解析.org / tags-html 

从上面的例外情况看,应用程序似乎没有找到 struts-taglib.jar 文件。



但我已将 struts-taglib.jar 放在 / WEB-INF / lib 目录中。那么问题出在哪里?


注意:您还可以查看 Java - 部署Web应用程序时出现问题以获取更多信息



解决方案

您说JAR确实出现在Web应用程序的WEB-INF / lib中;我会接受你的话并相信你。



我建议你打开 struts-taglib.jar ,打开标签库的.tld,并验证< uri>您在< taglib>下找到的值root匹配JSP中给定前缀的uri。我猜测URI不匹配,这意味着即使JAR位于CLASSPATH中,类加载器也无法找到标记库。



它还可能表明版本更改是否使您的JAR和JSP中的URI不同步。



<我刚刚下载了struts-1.3.10-all.zip并查看了其中包含的struts-logic.tld。 < uri> 标记的值为 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(相应地修改):

 < taglib> 
< taglib-uri> http://java.sun.com/jstl/core< / taglib-uri>
< taglib-location> /WEB-INF/c.tld< / taglib-location>
< / taglib>

这可能是因为Struts 1.0在这一点上相当陈旧。在开发Struts 1.0之后,将.tld打包在taglib的JAR中成为一种常见做法。


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

解决方案

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 is http://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):

<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.

这篇关于我的Web应用程序找不到Struts 1 - struts-taglib.jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆