一:建立的SpringBoot项目以后测试访问接口报错:spring
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.springboot
Thu Feb 28 23:18:21 CST 2019
There was an unexpected error (type=Not Found, status=404).
No message available
问题说明:
出现这个异常说明了跳转页面的url无对应的值.
缘由:
缘由1:
Application启动类的位置不对.要将Application(启动类)类放在最外侧,即包含全部子包,spring-boot会自动加载启动类所在包下及其子包下的全部组件.mvc
缘由2:
在springboot的配置文件:application.yml或application.properties中关于视图解析器的配置问题:
当pom文件下的spring-boot-starter-paren版本高时使用:
spring.mvc.view.prefix/spring.mvc.view.suffix
当pom文件下的spring-boot-starter-paren版本低时使用:
spring.view.prefix/spring.view.suffixapp
缘由3:
控制器的URL路径书写问题
@RequestMapping(“xxxxxxxxxxxxxx”)
实际访问的路径与”xxx”不符合.spring-boot
注解问题:由于个人代码以下 使用了@Controller和@RequestMapping两个注解,返回一个字符串并无对应的解析器,因此就会包错
解决方案:
将这两个注解换掉使用 @RestController 或者在 @RequestMapping("/hello") 这里加上@ResponseBody示意不用去找页面
@Controller
public class HelloController {
@RequestMapping("/hello")
public String hello(){
return "hello SpringBoot!!";
}
}
二: