简体   繁体   中英

JSTL tags are not working in eclipse

I am new to JSTL, I downloaded jstl-1.2.jar from here to my web-content/web-inf/lib folder. In my JSP file, I have mentioned:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

but everytime when I tries to use any JSTL tag, I got the error:

HTTP Status 500 - java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagLibraryValidator

I am using eclipse photon, tomcat server-8.0.52. What should I do? I have searched a lot on the internet about this, but I got the same errors. Please help me.

It seems that you are getting error during runtime! If you are using maven you must add JSTL dependency or if you are not using maven or gradle you must add the jar to the class path .

Oh sorry! TagLibraryValidator its your problem! add jsp-api-2.2.jar to your lib folder.

http://www.java2s.com/Code/Jar/j/Downloadjspapi22jar.htm

At last, I got the solution. I just reinstall my java, eclipse, server and reconfigure jstl-1.2.jar. It start working well. I don't know how but this is only solution for me.

ADD FOLLOWING DEPENDENCIES TO A WEB APPLICATION

To use this distribution with your own web applications, add the following JAR files to the '/WEB-INF/lib' directory of your application:

  • taglibs-standard-spec-1.2.5.jar
  • taglibs-standard-impl-1.2.5.jar
  • taglibs-standard-jstlel-1.2.5.jar
  • xalan-2.7.1.jar
  • serializer-2.7.1.jar

If you do not use JSTL 1.0 tags then the "taglibs-standard-jstlel" JAR may be omitted. If you do not use the XML library, then the Apache Xalan dependencies may also be omitted.

Sometimes only taglibs-standard-impl-1.2.5.jar library is enough. But if you want to use like forEach loop you should add two libraries to WEB-INF/lib of your project: Impl: taglibs-standard-impl-1.2.5.jar Spec: taglibs-standard-spec-1.2.5.jar

https://downloads.apache.org/tomcat/taglibs/taglibs-standard-1.2.5/README_bin.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM