This application has no explicit mapping for /error, so you are seeing this as a fallback.

完整报错如下:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
 
Mon Nov 19 10:43:58 CST 2018
There was an unexpected error (type=Not Found, status=404).
No message available

上面这句话大概的意思是,“这个应用没有明确的映射/错误,所以你才会看到这样一个返回结果”,这是我自己翻得,将就可以看,英语好的童鞋勿笑话哈。其实,我翻完之后都在想没有明显的问题是什么玩意,我又看到下面404心里就踏实了。

谷歌一下,针对以上错误出现的可能有一下几点:

一. Application启动类的位置不对

要将Application类放在最外侧,即包含所有子包spring-boot会自动加载启动类所在包下及其子包下的所有组件(有点不明觉厉的感觉,下面我们举个例子让这就话落落地让我们这种普通人也能看得懂)

这儿我总结了目前确认了三种错误案例

第一种,Application启动类直接放在了java包下面,这个在编译器就会报错

This application has no explicit mapping for /error, so you are seeing this as a fallback.

第二种,controller类跟Application启动类在同级包的不同包下边

This application has no explicit mapping for /error, so you are seeing this as a fallback.

第三种,启动类范围小于组件的位置范围

This application has no explicit mapping for /error, so you are seeing this as a fallback.

正确位置:在组件的同包或者组件的外层包内都可以,总之启动类的位置范围应大于或者等于组件所在位置。(原因就是上面那句不明觉厉的话)
This application has no explicit mapping for /error, so you are seeing this as a fallback.

二. 视图解析器的配置问题

在springboot的配置文件:application.yml或application.properties中关于视图解析器的配置问题(暂未碰到,后期碰到后再补充):
This application has no explicit mapping for /error, so you are seeing this as a fallback.
当pom文件下的spring-boot-starter-paren版本高时使用:spring.mvc.view.prefix/spring.mvc.view.suffix
当pom文件下的spring-boot-starter-paren版本低时使用::spring.view.prefix/spring.view.suffix

三. 控制器的URL路径书写问题:

@RequestMapping(“xxx”) ,实际访问的路径与”xxx”不符合

This application has no explicit mapping for /error, so you are seeing this as a fallback.

This application has no explicit mapping for /error, so you are seeing this as a fallback.

上一篇:《Seeing Out of the box End-to-End Pre-training for Vision-Language Representation Learning》2021论文阅读


下一篇:洛谷 P2984 [USACO10FEB]给巧克力Chocolate Giving