简体   繁体   English

JSTL 标签在 Eclipse 中不起作用

[英]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.我是 JSTL 的新手,我从这里下载了 jstl-1.2.jar 到我的 web-content/web-inf/lib 文件夹。 In my JSP file, I have mentioned:在我的 JSP 文件中,我提到过:

<%@ 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:但是每次当我尝试使用任何 JSTL 标签时,我都会收到错误消息:

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

I am using eclipse photon, tomcat server-8.0.52.我正在使用 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 .如果您使用的是 maven,则必须添加 JSTL 依赖项,或者如果您不使用 maven 或 gradle,则必须将 jar 添加到类路径中

Oh sorry!哦对不起! TagLibraryValidator its your problem! TagLibraryValidator 是您的问题! add jsp-api-2.2.jar to your lib folder.将 jsp-api-2.2.jar 添加到您的 lib 文件夹中。

http://www.java2s.com/Code/Jar/j/Downloadjspapi22jar.htm 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.我只是重新安装了我的 java、eclipse、server 并重新配置了 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:要将此发行版与您自己的 Web 应用程序一起使用,请将以下 JAR 文件添加到您的应用程序的“/WEB-INF/lib”目录中:

  • taglibs-standard-spec-1.2.5.jar taglibs-standard-spec-1.2.5.jar
  • taglibs-standard-impl-1.2.5.jar taglibs-standard-impl-1.2.5.jar
  • taglibs-standard-jstlel-1.2.5.jar taglibs-standard-jstrel-1.2.5.jar
  • xalan-2.7.1.jar xalan-2.7.1.jar
  • serializer-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.如果您不使用 JSTL 1.0 标记,则可以省略“taglibs-standard-jstel”JAR。 If you do not use the XML library, then the Apache Xalan dependencies may also be omitted.如果您不使用 XML 库,则也可以省略 Apache Xalan 依赖项。

Sometimes only taglibs-standard-impl-1.2.5.jar library is enough.有时只有 taglibs-standard-impl-1.2.5.jar 库就足够了。 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但是如果你想使用 forEach 循环,你应该在你的项目的 WEB-INF/lib 中添加两个库: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 https://downloads.apache.org/tomcat/taglibs/taglibs-standard-1.2.5/README_bin.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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