Why jstl is not working?

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.jarMET-INF *.tld files under to WEB-INFtld 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


    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.


    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 copy jstl.jar and standard.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

  • 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" %>
    
    链接地址: http://www.djcxy.com/p/74764.html

    上一篇: 无法获得工作在Apache Tomcat 8中的.jsp

    下一篇: 为什么jstl不工作?