Struts 1 - struts-taglib.jar is not being found by my web application

不打扰是莪最后的温柔 提交于 2019-12-23 03:19:12

问题


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


回答1:


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.




回答2:


Is /WEB-INF/lib in your classpath ?




回答3:


After deploying it is the jar file actually in /WEB-INF/lib ? If not will putting it by hand resolve the problem?




回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/2441254/struts-1-struts-taglib-jar-is-not-being-found-by-my-web-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!