赞
踩
因为在学习过程中,又遇到过此类问题,jsp页面找不到大部分还是路径问题。如果springboot在运行过程中,使用内嵌的tomcat插件启动的话,不妨通过下面的方式排查下jsp页面404的问题:
1.在“TomcatServletWebServerFactory”类。查看一下docBase的值到底是不是当前项目所在目录。(有可能是个临时空目录)
2.创建一个config类,配置一个Bean.
@Bean public WebServerFactoryCustomizer<TomcatServletWebServerFactory> customizer(){ return (factory)->{ factory.addContextCustomizers(context -> { String relatePath = "项目名称/src/main/webapp"; context.setDocBase(new File(relatePath).getAbsolutePath()); }); }; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。