问题
Like in the article , I have placed the following files in WEB-INF/lib folder of my applicaion
- Standard.jar (1.1.2)
- jstl.jar (1.1.2)
in taglib it states that it would resolve uri tag in the TLD of a taglib deployed in a jar file (WEB-INF/lib).
And my application keep throwing errors that it cannot found any tag libs.
When I extracted the Standard.jar\MET-INF *.tld files under to WEB-INF\tld folder, It worked and sorted. But still is there a cleaner way I could do it, So I may not need to update that taglibs separately other than replacing it with the new version?
Exception org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
回答1:
You probably don't have them in your build path. Placing them in libs folder may not be sufficient. In Eclipse for example: right click on project -> Build Path -> Configure Build Path ... Then in Libraries tab add your jars using Add External JARs button.
回答2:
You should not extract the JAR files and clutter your webapp project with its loose contents. Remove them all. You should not manually define the taglibs in web.xml
. Remove them all. You should not put them in some random /lib
folder and fiddle with IDE build path properties. Remove them all and undo the changed buildpath properties.
All you need to do is:
Download the zip, extract it, open its
/lib
folder and copyjstl.jar
andstandard.jar
files in/WEB-INF/lib
folder (thus, not/lib
) of your webapp. A bit decent IDE should already have created the/WEB-INF/lib
folder for you. You just have to drop the JARs in there.Declare the taglibs with proper URI in JSPs as per the tag documentation. For JSTL 1.1 Core taglib it's the following
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
(note the
/jsp
in the path, this is often overlooked because old JSTL 1.0 didn't have this)
See also:
- Our JSTL tag info page
回答3:
you need to define the taglib's information in web.xml like :
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
and this uri name you can use in jap like :
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
回答4:
You can check file web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
end in file .jsp add
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
来源:https://stackoverflow.com/questions/7579735/why-jstl-is-not-working