springboot项目浏览器报错:There was an unexpected error (type=Not Found, status=404).

springboot项目浏览器报错:There was an unexpected error (type=Not Found, status=404).

报错信息

springboot+thymeleaf项目,运行时页面报错信息如下:

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

Sat Dec 23 15:25:59 CST 2017
There was an unexpected error (type=Not Found, status=404).
No message available

解决方法

1、引入thymeleaf引擎

查看是否忘记引入了thymeleaf依赖,没有引入则在mawen的pom.xml文件引入,pom.xml文件的thymeleaf引入如下:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>          
</dependency>

2、检查访问地址是否正确

检查访问地址是否写正确,地址应该为controller的路径加上RequestMapping的路径。
如下代码的访问地址为:http://localhost:8080/getUList

@Controller
public class UlevelController {
    @RequestMapping(value="getUList", method=RequestMethod.GET)
    public String getUlevelList() {
        ………………
        return "ulevel/ulevelList";
    }
}

如下代码的访问地址为:http://localhost:8080/hhllow/getUList

@Controller
@RequestMapping(value="/hhllow")
public class UlevelController {
    @RequestMapping(value="getUList", method=RequestMethod.GET)
    public String getUlevelList() {
        ………………
        return "ulevel/ulevelList";
    }
}

这里顺便说明,如果访问的是hello.html,但是hello.html不存在,不是抛出404的错误,而是500的错误,如下信息:

Error resolving template "/hello", template might not exist or might not be accessible by any of the configured Template Resolvers 

如果看到如上信息,那么就要检查下模板文件是否存在,以及文件名称是否编写正确了。

3、包路径写对

application.java文件的包必须是项目下的父路径,其他类的包路径必须是其子路径,如:
路径

以下是我在其他地方看到的信息
引用

参考:http://412887952-qq-com.iteye.com/blog/2313575
http://quabr.com/36819277/i-keep-getting-this-error-there-was-an-unexpected-error-type-not-found-status

  • 28
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值