如何在升级Spring Boot时解决jstl错误



我正试图将Spring Boot从2.1.x版本升级到2.2.x版本,但我的jsp文件中包含的jstl一直存在问题。

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

我在等级设置中有这些依赖项

dependencies {
// Spring Boot
implementation 'org.springframework.boot:spring-boot-starter-web'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// Web
implementation 'javax.servlet:jstl:1.2'
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper:9.0.40'

在我的jsp文件中,我有这些包括

<!DOCTYPE html>
<%@ page language="java" pageEncoding="utf-8" contentType="text/html;charset=utf-8" %>
<%@ page trimDirectiveWhitespaces="true" session="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>

在使用SpringBoot版本2.1.x时,它一直在工作,但一旦我使用2.2.x,它就会出现上面描述的错误。

当我启动应用程序时,我在IntelliJ设置中使用此VM选项

-Dtomcat.util.scan.StandardJarScanFilter.jarsToScan=jstl*.jar,spring-webmvc*.jar

我没有web.xml文件,但我有一个web.config文件,我们在Azure中部署时使用它。但在本地测试时,这不应该是相关的。。。

关于如何解决这个问题,有什么想法吗?当我在发行说明中找不到任何与jsp或jstl相关的突破性更改时,为什么Spring Boot 2.2.x会打破这一点?

您将应用程序部署到哪个服务器?如果您实际将其部署到Azure中的Tomcat服务器中,则应将Tomcat嵌入式jasper依赖项标记为提供的

providedRuntime 'org.apache.tomcat.embed:tomcat-embed-jasper:9.0.40'

最新更新