spring boot jsp:java.lang.NoClassDefFoundError:org / apache / tomcat / util / security / Escape

问题描述 投票:0回答:1

我试图在我的春季启动应用程序中添加一个简单的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

我添加了spring boot web starter和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个回答
0
投票

我通过使用compileOnly修复了这个问题

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

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

© www.soinside.com 2019 - 2024. All rights reserved.