`

68. 使用thymeleaf报异常:Not Found, status=404【从零开始学Spring Boot】

阅读更多

 

 

 

【从零开始学习Spirng Boot—常见异常汇总】

 

       我们按照正常的流程编码好了 controller访问访问方法/hello,对应的是/templates/hello.html文件,但是在页面中还是抛出了错误信息:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jul 26 21:01:09 CST 2016
There was an unexpected error (type=Not Found, status=404).
No message available

 

这个错误有很多方面的原因,博主说说开发过程中博主碰到的情况:

 

第一种情况:是否忘记引入了thymeleaf依赖,检查pom.xml文件,是否有:

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

 

       有一次写例子就给忘了,结果就不可访问了。

 

第二情况:检查访问地址是否正确?

       不要是访问地址是/demo/hello,结果访问使用了/hello,那么肯定是无法访问的,以及模板文件的目录和hello.html文件是否正确。

这里顺便说明,如果访问的是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

  

 

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

 

 à悟空学院:https://t.cn/Rg3fKJD

学院中有Spring Boot相关的课程!点击「阅读原文」进行查看!

SpringBoot视频:http://t.cn/A6ZagYTi

Spring Cloud视频:http://t.cn/A6ZagxSR

SpringBoot Shiro视频:http://t.cn/A6Zag7IV

SpringBoot交流平台:https://t.cn/R3QDhU0

SpringData和JPA视频:http://t.cn/A6Zad1OH

SpringSecurity5.0视频:http://t.cn/A6ZadMBe

Sharding-JDBC分库分表实战http://t.cn/A6ZarrqS

分布式事务解决方案「手写代码」:http://t.cn/A6ZaBnIr

 

 

网易云课堂视频最新更新

第十一章 Spring Boot 日志

1、spring boot日志—理论

2、Spring Boot日志-logback

3、Spring Boot日志-log4j2

第十二章 Spring Boot 知识点2

1、spring boot 服务配置和部署

2、Spring Boot 定制URL匹配规则

 

 

历史章节

 

第一章 快速开始

1、Spring Boot之Hello World

2、Spring Boot之Hello World访问404

 

第二章 Spring Boot之JSON

1、spring boot返回json数据

2、Spring Boot完美使用FastJson解析JSON数据

 

第三章 Spring Boot热部署

1、Spring Boot热部署(springloader)

2、springboot + devtools(热部署)

 

第四章 Spring Boot数据库

1、Spring Boot JPA/Hibernate/Spring Data概念

2、Spring Boot JPA-Hibernate

3、Spring Boot Spring Data JPA介绍

4、Spring Boot JdbcTemplate

5、Spring Boot集成MyBatis

 

第五章 web开发

1、全局异常捕捉

2、配置server信息

3、spring boot使用thymeleaf

4、Spring Boot 使用freemarker

5、Spring Boot添加JSP支持

 

第六章 定时任务

1、Spring Boot定时任务

2、Spring Boot 定时任务升级篇(动态修改cron参数)

3、Spring Boot 定时任务升级篇(动态添加修改删除定时任务)

4、Spring Boot 定时任务升级篇(集群/分布式下的定时任务说明)

5、Spring Boot Quartz介绍

6、Spring Boot Quartz在Java Project中使用

7、Spring Boot 集成Quartz普通使用

8、Spring Boot 集成Quartz升级版

9、Spring Boot 集成Quartz二次升级版

10、Spring Boot 集成Quartz-Job如何自动注入Spring容器托管的对象

 

第七章 Spring Boot MyBatis升级篇

1、Spring Boot MyBatis升级篇-注解

2、Spring Boot MyBatis升级篇-注解-自增ID

3、Spring Boot MyBatis升级篇-注解-增删改查

4、Spring Boot MyBatis升级篇-注解-分页查询

5、Spring Boot MyBatis升级篇-注解-分页PageHelper不生效

6、Spring Boot MyBatis升级篇-注解- mybatic insert异常:BindingException: Parameter 'name' not found

7、Spring Boot MyBatis升级篇-注解- #和$符号特别篇

8、Spring Boot MyBatis升级篇-注解-@Result

9、Spring Boot MyBatis升级篇-注解-动态SQL(if test)-方案一:<script>

10、Spring Boot MyBatis升级篇-注解-动态SQL(if test)-方案二:@Provider

11、Spring Boot MyBatis升级篇-注解-动态SQL-参数问题

12、Spring Boot MyBatis升级篇-注解-特别篇:@MapperScan和@Mapper

13、Spring Boot MyBatis升级篇-XML

14、Spring Boot MyBatis升级篇-XML-自增ID

15、Spring Boot MyBatis升级篇-XML-增删改查

16、Spring Boot MyBatis升级篇-XML-分页查询

17、Spring Boot MyBatis升级篇-XML-分页PageHelper不生效

18、Spring Boot MyBatis升级篇-XML-动态SQL(if test)

19、Spring Boot MyBatis升级篇-XML-注解-初尝试

20、Spring Boot MyBatis升级篇- pagehelper替换为pagehelper-spring-boot-starter

 

第八章 Spring Boot 知识点1

1、Spring Boot 拦截器HandlerInterceptor

2、Spring Boot启动加载数据CommandLineRunner

3、Spring Boot环境变量读取和属性对象的绑定

4、Spring Boot使用自定义的properties

5、Spring Boot使用自定义的properties

6、Spring Boot使用@SpringBootApplication

7、Spring Boot 监控和管理生产环境

 

第十章 Spring Boot 打包部署

1、Spring Boot打包部署((提供Linux的sh文件))

 

第十一章 Spring Boot 日志

1、spring boot日志—理论

2、Spring Boot日志-logback

 

3、Spring Boot日志-log4j2

更多查看博客: http://412887952-qq-com.iteye.com/

 

分享到:
评论
2 楼 林祥纤 2016-10-04  
tzhz 写道
还有一种可能是自己写了Scan目录所致:@ComponentScan(basePackages={"com.xxxx"})


恩恩,这种就得看自己实际的项目的结构了,出现的问题的地方还是挺多的,在这里只能说说常见的几种情况。
1 楼 tzhz 2016-10-02  
还有一种可能是自己写了Scan目录所致:@ComponentScan(basePackages={"com.xxxx"})

相关推荐

    thymeleaf-extras-java8time-3.0.4.RELEASE-API文档-中英对照版.zip

    Maven坐标:org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.4.RELEASE; 标签:extras、thymeleaf、java8time、jar包、java、中英对照文档; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件...

    thymeleaf-extras-java8time-3.0.1.RELEASE-API文档-中文版.zip

    Maven坐标:org.thymeleaf.extras:thymeleaf-extras-java8time:3.0.1.RELEASE; 标签:extras、thymeleaf、java8time、jar包、java、API文档、中文版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”...

    thymeleaf-spring5-3.0.14.RELEASE-API文档-中文版.zip

    赠送jar包:thymeleaf-spring5-3.0.14.RELEASE.jar 赠送原API文档:thymeleaf-spring5-3.0.14.RELEASE-javadoc.jar 赠送源代码:thymeleaf-spring5-3.0.14.RELEASE-sources.jar 包含翻译后的API文档:thymeleaf-...

    Java学习资料-SpringBoot自带模板引擎Thymeleaf使用详解

    - `spring.thymeleaf.prefix`:模板文件的路径前缀,默认为 `classpath:/templates/`。 - `spring.thymeleaf.suffix`:模板文件的后缀,默认为 `.html`。 - `spring.thymeleaf.cache`:是否启用缓存,默认为 `true`...

    thymeleaf-spring5-3.0.14.RELEASE-API文档-中英对照版.zip

    赠送jar包:thymeleaf-spring5-3.0.14.RELEASE.jar; 赠送原API文档:thymeleaf-spring5-3.0.14.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-spring5-3.0.14.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    thymeleaf-3.0.5.zip

    thymeleaf-3.0.5中文文档,清晰无广告,官方中文翻译 1.Thymeleaf简介 2.示例项⽬:Good Thymes Virtual Grocery 3.使⽤⽂本 4.标准表达式语法 5.设置属性值 6.循环迭代 7.条件判断 8.模板布局 9.局部变量 10.属性...

    从零开始学Spring Boot

    1.6 Spring Boot使用别的json解析框架 1.7 全局异常捕捉 1.8 Spring Boot datasource - mysql 1.9 JPA - Hibernate 1.10 使用JPA保存数据 1.11 使用JdbcTemplate 1.12 Spring Boot修改端口号 1.13 Spring Boot配置...

    thymeleaf-spring4-3.0.3.RELEASE-API文档-中文版.zip

    赠送jar包:thymeleaf-spring4-3.0.3.RELEASE.jar; 赠送原API文档:thymeleaf-spring4-3.0.3.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-spring4-3.0.3.RELEASE-sources.jar; 包含翻译后的API文档:...

    thymeleaf-spring5-3.0.10.RELEASE-API文档-中英对照版.zip

    赠送jar包:thymeleaf-spring5-3.0.10.RELEASE.jar; 赠送原API文档:thymeleaf-spring5-3.0.10.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-spring5-3.0.10.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    spring-boot-starter-thymeleaf-2.1.0.RELEASE.jar

    java运行依赖jar包

    thymeleaf-spring5-3.0.10.RELEASE-API文档-中文版.zip

    赠送jar包:thymeleaf-spring5-3.0.10.RELEASE.jar; 赠送原API文档:thymeleaf-spring5-3.0.10.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-spring5-3.0.10.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    thymeleaf-spring4-3.0.3.RELEASE-API文档-中英对照版.zip

    赠送jar包:thymeleaf-spring4-3.0.3.RELEASE.jar; 赠送原API文档:thymeleaf-spring4-3.0.3.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-spring4-3.0.3.RELEASE-sources.jar; 包含翻译后的API文档:...

    thymeleaf-spring5-3.0.12.RELEASE-API文档-中文版.zip

    赠送jar包:thymeleaf-spring5-3.0.12.RELEASE.jar; 赠送原API文档:thymeleaf-spring5-3.0.12.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-spring5-3.0.12.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    thymeleaf-extras-springsecurity-3.0-master.zip

    This module provides a new dialect called org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect or org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect (depending on the ...

    thymeleaf-3.0.12.RELEASE-API文档-中英对照版.zip

    赠送jar包:thymeleaf-3.0.12.RELEASE.jar; 赠送原API文档:thymeleaf-3.0.12.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-3.0.12.RELEASE-sources.jar; 赠送Maven依赖信息文件:thymeleaf-3.0.12.RELEASE.pom;...

    thymeleaf-3.0.11.RELEASE-API文档-中文版.zip

    赠送jar包:thymeleaf-3.0.11.RELEASE.jar; 赠送原API文档:thymeleaf-3.0.11.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-3.0.11.RELEASE-sources.jar; 赠送Maven依赖信息文件:thymeleaf-3.0.11.RELEASE.pom;...

    thymeleaf-3.0.3.RELEASE-API文档-中文版.zip

    赠送jar包:thymeleaf-3.0.3.RELEASE.jar; 赠送原API文档:thymeleaf-3.0.3.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-3.0.3.RELEASE-sources.jar; 包含翻译后的API文档:thymeleaf-3.0.3.RELEASE-javadoc-...

    Spring boot 示例 官方 Demo

    spring-boot-helloWorld:spring-boot的helloWorld版本 spring-boot-mybaits-annotation:注解版本 spring-boot-mybaits-xml:xml配置版本 spring-boot-mybatis-mulidatasource:springboot+mybatis多数据源最简解决...

    thymeleaf-spring5-3.0.11.RELEASE-API文档-中英对照版.zip

    赠送jar包:thymeleaf-spring5-3.0.11.RELEASE.jar; 赠送原API文档:thymeleaf-spring5-3.0.11.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-spring5-3.0.11.RELEASE-sources.jar; 赠送Maven依赖信息文件:...

    thymeleaf-3.0.12.RELEASE-API文档-中文版.zip

    赠送jar包:thymeleaf-3.0.12.RELEASE.jar; 赠送原API文档:thymeleaf-3.0.12.RELEASE-javadoc.jar; 赠送源代码:thymeleaf-3.0.12.RELEASE-sources.jar; 赠送Maven依赖信息文件:thymeleaf-3.0.12.RELEASE.pom;...

Global site tag (gtag.js) - Google Analytics