In case you're already on Tomcat 10 or newer (the first Jakartified version, with jakarta.* package instead of javax.* package), use JSTL 2.0 via this sole dependency:<dependency> <groupId>org.glassfish.web</groupId> <artifactId>jakarta.servlet.jsp.jstl</artifactId> <version>2.0.0</version></dependency>非Maven用户可以通过将以下两个物理文件拖放到Web应用程序项目的/WEB-INF/lib文件夹中来实现相同目的(绝对不要丢弃standard * .jar或任何松散的.tld文件)在那里!如有必要,请将其删除.)Non-Maven users can achieve the same by dropping the following two physical files in /WEB-INF/lib folder of the web application project (do absolutely not drop standard*.jar or any loose .tld files in there! remove them if necessary). jakarta.servlet.jsp.jstl-2.0.0.jar (这是EE4J的JSTL 2.0实现) jakarta.servlet.jsp.jstl-api-2.0.0.jar (这是JSTL 2.0 API)jakarta.servlet.jsp.jstl-2.0.0.jar (this is the JSTL 2.0 impl of EE4J)jakarta.servlet.jsp.jstl-api-2.0.0.jar (this is the JSTL 2.0 API)如果您尚未使用Tomcat 10,但仍使用Tomcat 9或更早版本,请通过以下唯一依赖项使用JSTL 1.2:In case you're not on Tomcat 10 yet, but still on Tomcat 9 or older, use JSTL 1.2 via this sole dependency:<dependency> <groupId>org.glassfish.web</groupId> <artifactId>jakarta.servlet.jsp.jstl</artifactId> <version>1.2.6</version></dependency>非Maven用户可以通过将以下两个物理文件拖放到Web应用程序项目的/WEB-INF/lib文件夹中来实现相同目的(绝对不要丢弃standard * .jar或任何松散的.tld文件)在那里!如有必要,请将其删除.)Non-Maven users can achieve the same by dropping the following two physical files in /WEB-INF/lib folder of the web application project (do absolutely not drop standard*.jar or any loose .tld files in there! remove them if necessary). jakarta.servlet.jsp.jstl-1.2.6.jar (这是EE4J的JSTL 1.2体现) jakarta.servlet.jsp.jstl-api-1.2.7.jar (这是JSTL 1.2 API)jakarta.servlet.jsp.jstl-1.2.6.jar (this is the JSTL 1.2 impl of EE4J)jakarta.servlet.jsp.jstl-api-1.2.7.jar (this is the JSTL 1.2 API)如果您实际上使用的是普通的Jakarta EE服务器(如WildFly,Payara等),而不是诸如Tomcat,Jetty等的准系统servlet容器,则根本不需要显式安装JSTL.普通的Jakarta EE服务器已经 提供了现成的JSTL.换句话说,您无需将JSTL添加到pom.xml,也无需删除webapp中的任何JAR/TLD文件.仅provided作用域的Jakarta EE坐标就足够了:In case you're actually using a normal Jakarta EE server such as WildFly, Payara, etc instead of a barebones servletcontainer such as Tomcat, Jetty, etc, then you don't need to explicitly install JSTL at all. Normal Jakarta EE servers already provide JSTL out the box. In other words, you don't need to add JSTL to pom.xml nor to drop any JAR/TLD files in webapp. Solely the provided scoped Jakarta EE coordinate is sufficient:<dependency> <groupId>jakarta.platform</groupId> <artifactId>jakarta.jakartaee-api</artifactId> <version><!-- 9.0.0, 8.0.0, etc depending on your server --></version> <scope>provided</scope></dependency>确保web.xml版本正确此外,您还应确保您的web.xml被声明为至少符合 Servlet 2.4,因此不应低于Servlet 2.3或更早的版本.否则,JSTL标记内的EL表达式将无法正常工作.选择与目标容器匹配的最高版本,并确保在web.xml中的任何地方都没有<!DOCTYPE>.这是一个与Servlet 5.0(Tomcat 10)兼容的示例:Make sure web.xml version is rightFurther you should also make sure that your web.xml is declared conform at least Servlet 2.4 and thus not as Servlet 2.3 or older. Otherwise EL expressions inside JSTL tags would in turn fail to work. Pick the highest version matching your target container and make sure that you don't have a <!DOCTYPE> anywhere in your web.xml. Here's a Servlet 5.0 (Tomcat 10) compatible example:<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" version="5.0"> <!-- Config here. --></web-app>这是一个与Servlet 4.0(Tomcat 9)兼容的示例:And here's a Servlet 4.0 (Tomcat 9) compatible example:<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <!-- Config here. --></web-app>另请参见: JSTL核心标签库文档(针对正确的taglib URI) 未在JSP中评估的EL表达式 如何为Tomcat 10+或Tomcat 9- 配置pom.xmlSee also:JSTL core taglib documentation (for the right taglib URIs)EL expressions not evaluated in JSPHow to configure pom.xml for Tomcat 10+ or Tomcat 9- 这篇关于如何安装JSTL?绝对URI:无法解析http://java.sun.com/jstl/core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!