【问题标题】:Spring Boot 3 JSP IssueSpring Boot 3 JSP 问题
【发布时间】:2023-01-08 11:50:00
【问题描述】:

自从迁移到 Java 17 和 Spring Boot 3 以来,我一直遇到 JSP 问题。我知道我们需要使用 jakarta.* 而不是 javax.*,但我是否遗漏了什么?我正在使用 Spring Tools 4,并且只是使用 JSP 运行一个基本的 Web 应用程序。使用以下依赖项时

  <dependency>
    <groupId>jakarta.servlet</groupId>
    <artifactId>jakarta.servlet-api</artifactId>
    <scope>provided</scope>
  </dependency>
  <dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>jakarta.servlet.jsp.jstl</artifactId>
  </dependency>

项目运行,但出现以下错误

The superclass "javax.servlet.http.HttpServlet", determined from the Dynamic Web Module facet version (2.5), was not found on the Java Build Path

我可以通过添加 javax servlet 依赖项来摆脱它

  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>4.0.1</version>
    <scope>provided</scope>
  </dependency>

但这与在 Spring Boot 3 中使用 javax.* 依赖项背道而驰。

我已阅读这些文章并尝试添加 jakarta.servlet.jsp 依赖项但没有成功。

https://debugah.com/solved-tomcat10-error-jakarta-servlet-servletexception-class-com-kuang-servlet-helloservlet-is-not-a-servlet-22749/

https://howtodoinjava.com/java/exception-handling/solved-the-superclass-javax-servlet-http-httpservlet-was-not-found-on-the-java-build-path-in-eclipse/

【问题讨论】:

    标签: spring-boot maven jsp jakarta-ee dependencies


    【解决方案1】:

    解决了!

    我所要做的就是进入项目属性及以下项目面, 改变我的动态网络模块2.55.0

    可以在下面抑制 JSTL 警告属性->Web->JSP 文件->验证->自定义操作->TagExtraInfo 类的其他问题(只需将“警告”更改为“忽略”)

    【讨论】:

      猜你喜欢
      • 2016-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 2022-12-31
      • 2019-06-11
      • 2017-12-21
      相关资源
      最近更新 更多