springboot + tomcat + jsp 报Whitelabel Error Page解决方法
2018-02-24 10:34
991 查看
网上都说springboot是一个快捷搭建的开发框架,就像尝试下。但是在使用的过程当中发现加入jsp后按照原有的springmvc方式报Whitelabel Error Page错误,查遍网上所有遇到的同类问题,大致如下:
[html] view plain copy<span style="font-size:18px;">Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Jun 11 09:07:08 CST 2017
There was an unexpected error (type=Not Found, status=404).
No message available</span>
问题很像是没有访问地址不对,第一感觉以为url写的不对。
其实不是,真正的原因是【Application启动类放的位置不对】要将Application放在最外层,也就是要包含所有子包。
比如你的groupId是com.google,子包就是所谓的com.google.xxx,所以要将Application类要放在com.google包下。
springboot会自动加载启动类所在包下及其子包下的所有组件.
排查后不存在这问题,还有一些其他的解决方法都尝试还是不行。最终在spring官网找到
这个demo,大家都知道jsp是依靠于servlet容器运行的,看demo如下代码:
spring boot 入口类需要继承SpringBootServletInitializer servlet初始化类,这样就ok了。
[html] view plain copy<span style="font-size:18px;">Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sun Jun 11 09:07:08 CST 2017
There was an unexpected error (type=Not Found, status=404).
No message available</span>
问题很像是没有访问地址不对,第一感觉以为url写的不对。
其实不是,真正的原因是【Application启动类放的位置不对】要将Application放在最外层,也就是要包含所有子包。
比如你的groupId是com.google,子包就是所谓的com.google.xxx,所以要将Application类要放在com.google包下。
springboot会自动加载启动类所在包下及其子包下的所有组件.
排查后不存在这问题,还有一些其他的解决方法都尝试还是不行。最终在spring官网找到
这个demo,大家都知道jsp是依靠于servlet容器运行的,看demo如下代码:
spring boot 入口类需要继承SpringBootServletInitializer servlet初始化类,这样就ok了。
相关文章推荐
- Spring-Boot "Whitelabel Error Page" 解决方法总结
- spring-boot jsp whitelabel error page问题解决
- spring-boot集成 jsp报whitelabel error page的问题解决
- spring boot2.0 创建 及 mvc视图映射 jsp时 Whitelabel Error Page(一)
- Spring Boot Whitelabel Error Page解决办法
- Spring boot JSP访问页面显示Whitelabel Error Page
- SpringBoot中jsp页面调用iframe标签报Whitelabel Error Page 错误
- 初学Spring Boot遇到Whitelabel Error Page的解决办法
- 《Springboot极简教程》问题解决:Springboot启动报错 Whitelabel Error Page: This application has no explicit mapping for
- 《Springboot极简教程》问题解决:Springboot启动报错 Whitelabel Error Page: This application has no explicit mapping for(转)
- Spring Boot : Whitelabel Error Page解决方案
- SpringBoot接口服务处理Whitelabel Error Page
- SpringBoot 访问出错Whitelabel Error Page
- 初学 Spring boot 报错 Whitelabel Error Page 404
- SpringBoot 不显示Whitelabel Error Page
- spring boot: Whitelabel Error Page的解决方案
- 搭建Spring Boot框架 Whitelabel Error Page This application has no explicit mapping for /error, so you ar
- Spring Boot自定义错误页面,Whitelabel Error Page处理方式
- Spring Boot自定义错误页面,Whitelabel Error Page处理方式
- spring boot: Whitelabel Error Page的解决方案