【问题标题】:spring boot jsp : java.lang.NoClassDefFoundError: org/apache/tomcat/util/security/Escape春季启动jsp:java.lang.NoClassDefFoundError:org/apache/tomcat/util/security/Escape
【发布时间】:2018-10-22 07:58:32
【问题描述】:

我正在尝试在我的 Spring Boot 应用程序中添加一个简单的 jsp 渲染。

@Controller
public class WelcomeController {    
    @RequestMapping("/index")
    public String loginMessage(){
        return "index";
    }
}

解析器

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

和/src/main/webapp/WEB-INF/jsp/index.jsp

我添加了 sprng boot web stater 和 tomcat embed

compile('org.springframework.boot:spring-boot-starter-web')
compile('org.apache.tomcat.embed:tomcat-embed-jasper')

我遇到了这个问题

May 11, 2018 3:54:53 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [java.lang.NoClassDefFoundError: org/apache/tomcat/util/security/Escape] with root cause
java.lang.ClassNotFoundException: org.apache.tomcat.util.security.Escape

【问题讨论】:

    标签: jsp spring-boot


    【解决方案1】:

    我通过使用 compileOnly 解决了这个问题

    compile('org.springframework.boot:spring-boot-starter-web')
    compileOnly('org.apache.tomcat.embed:tomcat-embed-jasper')
    

    仅编译类似于 maven 中提供的范围。

    【讨论】:

      猜你喜欢
      • 2014-06-26
      • 2023-03-05
      • 2021-07-14
      • 2016-04-25
      • 2017-09-11
      • 2015-04-18
      • 2017-06-24
      • 2015-08-22
      相关资源
      最近更新 更多