《Spring Boot实战派》 实例7实现MVC模式的Web应用程序 遇到的问题

Error resolving template [mvcdemo], template might not exist or might not be accessible
by any of the configured Template Resolvers] with root cause

主要原因是模板没找到,说明resource文件可能有问题

第一步:
确保启动文件的位置,这里是MvcDemoApplication,放在最外侧,和子包并列或者处于外侧,这里的子包是contrller和model ,spring-boot会自动加载启动类所在包及其子包下的所有组件

第二步:
需要配置application.properties文件中视图解析器,笔者这一步出现错误
需要配置成如下

#配置前缀
#spring.thymeleaf.prefix=classpath:/templates/
#配置后缀
#spring.thymeleaf.suffix=.html

Thymeleaf模版默认会使用templates作为视图文件

第三步
注意@Controller中试图模板的名字和resource文件下的html文件名字相匹配。

  //定义mvc中的视图模板ModelAndView modelAndView=new ModelAndView("mvcdemo");//需要和html文件名相匹配

第四步
确保@GetMapping("/mvcdemo")和控制器url访问路径一致

参考博客SpringBoot—静态页面加载
参考博客异常:This application has no explicit mapping for /error, so you are seeing this as a fallback.

异常:This application has no explicit mapping for /error.以及spring.mvc.view.prefix配置解决相关推荐

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

    初学springboot配置好文件,测试接口出现这个是springboot的启动器要放在dao service-包的上层目录

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

    文章目录 SpringBoot This application has no explicit mapping for /error, so you are seeing this as a fal ...

  3. 异常:This application has no explicit mapping for /error, so you are seeing this as a fallback解决方法

    目录 一.错误提示: 二.原因: 三.解决方法1,移动控制层的包: ​四.解决方法二,添加@SpringBootApplication(scanBasePackages="controlle ...

  4. spring,Whitelabel Error Page,This application has no explicit mapping for /error, so you are seeing

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

  5. P16对member进行代码生成时,访问端口出现This application has no explicit mapping for /error, so you are seeing this

    P16时,当对member进行代码生成时,访问端口出现This application has no explicit mapping for /error, so you are seeing th ...

  6. 解决:Whitelabel Error Page This application has no explicit mapping for /error...UnknownHostException

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 1. 我的情况 : springcloud 实践,启动 ribbon 工程后,请求接口报错: Whi ...

  7. 查询商品列表报错This application has no explicit mapping for /error, so you are seeing this as a fallback

    1.问题: Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing t ...

  8. 当出现Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this

    Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as ...

  9. Whitelabel Error PageThis application has no explicit mapping for /error, so you are seeing this as

    IDEA运行简单spingboot浏览器页面报错信息: Whitelabel Error Page This application has no explicit mapping for /erro ...

最新文章

  1. 卡尔曼滤波器的特殊案例
  2. Hive JDBC:Permission denied: user=anonymous, access=EXECUTE, inode=”/tmp”
  3. gitlab修改配置重启_centos7下gitlab安装说明
  4. JMS : Java Message Service (Java消息服务)之一 [转]
  5. 工作182:表格渲染
  6. HTML5 基础知识
  7. node.js的下载和安装
  8. Requests库常用方法及其详解
  9. 【Django 2021年最新版教程1】windows10+python3.9.5+pycharm2021.1.1+Django3.2.3新建一个web项目 教程
  10. matplotlib绘制横向柱状图
  11. 澳大利亚IT解决方案提供商使用OpManager节省了数万美元的IT维护成本
  12. 火电厂给水串级控制系统仿真
  13. c语言计算矩阵的n次方,N矩阵的n次方运算及折半查找报告--数据结构(C语言)
  14. flickr网站用到的php技术
  15. Reducing Language Biases in Visual Question Answering with Visually-Grounded Question Encoder 论文笔记
  16. 计算多边形中心点坐标的方法
  17. 为什么Word字间距异常的大?怎么修正排版?
  18. 聚合资金托管+支付 联动优势推出房产行业线上产品“海金居”
  19. 【OriginPro使用】FFT绘制信号频谱图
  20. 【智能优化算法】基于矮猫鼬优化算法求解单目标优化问题附matlab代码

热门文章

  1. itools下载链接被360警告:虚假招聘网站
  2. 10个开源的PHP网站内容管理系统
  3. wap站点优于传统站点的异同分析
  4. 第四章 进程(3)进程的命令行环境变量
  5. 【转载】说说大型高并发高负载网站的系统架构
  6. 最远的你是我最近的爱
  7. 求职过程记录(5)——黎明到来
  8. python输入一组身高_一起学Python系列之用户输入
  9. android自适应拉伸图片,Android 启动页-解决图片被拉伸和压缩问题,适配虚拟导航栏...
  10. oracle安装参数,Oracle安装内核参数设置