首页 > 其他分享 >68. 使用thymeleaf报异常:Not Found, status=404

68. 使用thymeleaf报异常:Not Found, status=404

时间:2023-07-06 22:32:02浏览次数:36  
标签:status Spring boot Boot 升级 thymeleaf 404 MyBatis 注解


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

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

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

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

 

第一种情况:是否忘记引入了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 anyof the configured Template Resolvers 

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

 

 

 

 

 

 

网易云课堂视频最新更新

第十一章 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

 

标签:status,Spring,boot,Boot,升级,thymeleaf,404,MyBatis,注解
From: https://blog.51cto.com/u_11142439/6646232

相关文章

  • ios系统微信浏览器打开H5,调用接口status = 0失败的问题?
    最近写了一个很简单的小项目,以为不会有什么问题,今天突然说出问题了,说ios用户打开没有请求到数据。经测试,安卓,pc,都没有问题,只有ios出问题了。因为这次的涉及到时间,我以为ios时间处理上出问题了,仔细看了看,并不是,于是开启了漫长的寻找bug的过程。使用vConsole查看接口请求情况,发现......
  • 5分钟学会img标签加载图片404错误解决方案
      在开发中,使用<imgsrc="/img/yys.png"/>加载图片时,会有404错误,也就是图片未找到问题。  现将解决办法 总结如下:  当图片未找到或者404时,就会触发<img/>标签的 onerror属性显示其中的图片。1、直接拼写路径方式:<imgsrc="img/yys.png"onerror="javascript......
  • ASP.NET MVC PUT DELETE 404 C# mvc delete put 失败
    对于使用Url路由访问页面的ASP.NET应用程序,IIS可能会显示404,403之类的错误代码,而且排除了代码问题(本地运行正常),那么就可以加下面这句话:<system.webServer><modules><removename="UrlRoutingModule-4.0"/><addname="UrlRoutingModule-4.0"type="......
  • 第四天(Thymeleaf,MVC自动配置原理,,配置项目环境及首页,页面国际化,登录+拦截器)
    ThymeleafMVC自动配置原理ContentNegotiatingViewResolver内容协商视图解析器转换器和格式化器配置项目环境及首页页面国际化中英切换登录+拦截器......
  • 动态路由-刷新页面时的 短暂404 bug修复
    动态路由-刷新页面时的bug修复1.问题说明如果我们手动刷新浏览器网页,会发现跳到了404页面对于addRoute添加的路由,在刷新时会白屏 2.问题分析解决页面刷新时,页面404问题在静态路由后面有一个路由通配符,addRoutes添加的路由是异步添加的。路由设置中的404页处在中间位置,而......
  • 将MembershipCreateStatus枚举成员翻译成自定义信息
    publicstaticclassAccountValidation{publicstaticstringErrorCodeToString(MembershipCreateStatuscreateStatus){switch(createStatus){caseMembershipCreateStatus.DuplicateUserName:......
  • 解决minio使用nginx代理出现问题(上传文件可以,创建桶404)
    minio使用nginx代理出现问题(上传文件可以,创建桶失败)server{listen80;#error_page500502503504404/404.html;注释掉location/{proxy_set_headerX-Forwarded-Proto$scheme;proxy_set_headerX-Real-IP$remote_addr;......
  • package-lock.json锁定镜像地址404的处理方法
    前言最近接触了一个新的vue项目,安装依赖是一直无法安装成功,有部分依赖包的地址报404,查看package-lock.json,发现其中部分依赖使用了公司私有的镜像库,但是目前该镜像库已关闭,访问该包地址返回404.解决方案如下1、删除package-lock.json,重新npmi生成新的package-lock.json2、先卸......
  • 在EasyCVR中调用快照接口返回404是什么原因?如何解决?
    EasyCVR视频融合平台基于云边端一体化架构,能在复杂的网络环境中将前端设备进行统一集中接入,实现视频资源的汇聚管理、直播鉴权、转码处理、多端分发、智能告警、数据共享等能力与服务。此外,平台也提供了丰富的API接口供用户自由调用、集成与二次开发。有用户反馈,在EasyCVR中调用......
  • SAP UI5 控件 ObjectStatus 的使用方法介绍试读版
    ObjectStatus控件是SAPUI5控件集合中一个极具视觉表现力的控件,用于在应用程序中显示实体(Object)的状态(Status)或属性信息。它可用于向用户提供重要的上下文状态信息,如成功、错误、警告、进行中(InProcess)等等。ObjectStatus控件通常与其他SAPUI5控件(如列表项、表格......