SpringBoot 无法显示html文件 找不到html文件 如果显示html文件
两种情况:
1、如果使用了 thymeleaf 模板引擎,html文件可以放在 template文件夹中,如果不是一定不要放进去,否则找不到,因为html是静态页面,所以放在把此类文件放在了static文件夹下。
15、springboot访问html文件
在pom.xml加入

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> </dependencies>

在resources\templates\hello.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Hello World!</title>
</head>
<body>
<h1 th:inline="text">Hello.v.2</h1>
<p th:text="${hello}"></p>
</body>
</html>

在Controller中加入
@RequestMapping("/hello")
public String helloHtml(HashMap<String,Object> map){
map.put("hello","hello");
return"/hello";
}
启动,然后输入localhost:8080/hello
会跳转到页面
注意:必须加入thymeleaf包,不然找不到
2、如果没有使用任何模板引擎,则html文件要放在static文件夹中,因为属于静态文件。


SpringBoot 无法显示html文件 找不到html文件 如果显示html文件的更多相关文章
- javah编译class文件找不到android.app.Activity的类文件
在android工程的根目录使用javah生成jni 头文件时候,报找不到android.app.Activity的类文件错误. 无法访问android.app.Activity是说明没有引入andr ...
- Failed to load resource: the server responded with a status of 404 (Not Found) favicon.ico文件找不到
今天使用sublime以localhost方式打开html文件时(使用wamp环境提供一个Apache服务器,html文件存在于wamp环境的www文件夹下),出现favicon.ico文件找不到 ...
- win10找不到hosts文件(设置显示隐藏文件也找不到)解决方法
Win10系统中的Hosts文件有很多作用,屏蔽网址,指定解析,跳转等等,所以我们经常会通过编辑Hosts文件来达成一些目的,一般来说hosts文件是隐藏的,我们需要显示受保护的文件才可以,但是有一些 ...
- 编译过程中,termcap.h 文件找不到路径 licli.a终于生成
编译过程中,termcap.h 文件找不到路径 查看是linux 源码下找不到termcap.h文件 安装了所有关于*cap*的源码包也不起作用 今天终于解决了这个问题,搜 ...
- iOS开发中遇到的头文件找不到的问题解决办法
有时会遇到莫名其妙的明明有这个文件,但是就是显示头文件找不到,我也是咨询了技术大牛之后知道的这个方法,之后恰巧我一个朋友问我cocoapod加进去之后头文件找不到,我就让他试了下这个方法果然好用,我也 ...
- 如何在 Linux 中找出最近或今天被修改的文件
1. 使用 ls 命令,只列出你的 home 文件夹中今天的文件. ls -al --time-style=+%D | grep `date +%D` 其中: -a- 列出所有文件,包括隐藏文件 -l ...
- create-react-app创建的项目npm run build之后静态文件找不到
create-react-app创建的项目npm run build之后,运行build中的index.html,什么都没显示,打开浏览器的F12,发现了几个红色的报错,提示几个文件找不到. 查看生成 ...
- 报错解决——Failed to load resource: the server responded with a status of 404 (Not Found) favicon.ico文件找不到
Django项目开发完成后在本地运行没问题,但在推到服务器上后出现报错Failed to load resource: the server responded with a status of 40 ...
- iOS学习——(转)解决iOS App打包后dSYM文件找不到的问题
dSYM文件缺失通常有两种情况**: 情况一:配置错误导致打包时没有生成dSYM文件 针对这种情况,通常是因为Project -> Build Settings下的Debug Informati ...
- iOS开发中遇到的错误整理 - 集成第三方框架时,编译后XXX头文件找不到
iOS编译报错-XXX头文件找不到 错误出现的情况: 自己在继承第三方的SDK的时候,明明导入了头文件,但是系统报错,提示头文件找不到 解决方法 既然系统找不到,给他个具体路径,继续找去! 路径就填写 ...
随机推荐
- Nginx(七):keepalived实现Nginx负载均衡服务器的双机高可用
前言 之前咱们通过 Nginx(六):Nginx HTTP负载均衡和反向代理的配置与优化 和 Nginx+tomcat组合实现高并发场景的动静分离和负载均衡方案 这两篇文章了解了Nginx对高并发应用 ...
- centos 7 安装python3和pip
目前,我认为还是使用系统自带的稳定版最好,因为:该版本肯定是centos7开发组深思熟虑的,稳定性好,另外,由于系统自带,兼容性好,第三,和之配套的软件齐全,如果不用系统的,建议还是不要在源码编译安装 ...
- mysql中tinyint、smallint、int、bigint的区别
tinyint 从 -2^7 (-128) 到 2^7 - 1 (123) 的整型数据.存储大小为 1 个字节. unsigned 是从 0 到 255 的整型数据. 所以建表的时候 只能是tinyi ...
- redis中键空间通知
通过redis的键空间通知,当redis删除过期key的时候,及时更新mongodb数据库中user的状态 var Redis = require('ioredis'); var redis = ne ...
- 在sublime text3中安装git插件
使用Package Control组件(推荐),打开install package控制台后,直接输入git就可以安装git插件. 这个时候Sublime Text只是安装了git插件,但还不能使用gi ...
- [Windows Azure] Building worker role A (email scheduler) for the Windows Azure Email Service application - 4 of 5.
Building worker role A (email scheduler) for the Windows Azure Email Service application - 4 of 5. T ...
- 如何优雅的退出/关闭/重启gunicorn进程
在工作中,会发现gunicorn启动的web服务,无论怎么使用kill -9 进程号都是无法杀死gunicorn,经过我一番百度和谷歌,发现想要删除gunicorn进程其实很简单. 1. 寻找mast ...
- 【Cmd】那些年,我们迷恋的cmd命令(一)
小续 还记得,那些年玩hack的朋友吗,现在玩这个的,基本都是小孩子了(俗称脚本小子). 还记得,那些年敲过的命令吗,现在的孩子,都用工具了(叫工具党). 孩子们,健康的网络环境需要大家一起去维护. ...
- kali下添加PATH环境变量
添加PATH环境变量,第1种方法: [root@lx_web_s1 ~]# export PATH=/usr/local/webserver/mysql/bin:$PATH 再次查看: [root@l ...
- vue 实现右键功能
@contextmenu.prevent="rightShow()" v-on:contextmenu.prevent = "事件名称"