SpringBoot不使用模板引擎直接返回html
一、在resource目录下面建立文件夹,里面方静态页面。
路径:src\main\resources\static\page\index.html
访问:http://localhost:8080/page/index.html
注意:后缀一定要html或者htm,否则打不开。
二、Spring Controller返回页面
访问:http://localhost:8080/index
注意:前端不能获取后台传递值,因为html不支持EL表达式。jsp或者模板引擎才支持
@Controller
public class HelloController { @RequestMapping("/index")
public String index(){
System.out.println("coming......");
return "page/index.html";
} @RequestMapping("/index2")
public ModelAndView index2(ModelAndView modelAndView){
System.out.println("coming......");
modelAndView.addObject("name","tom");
modelAndView.setViewName("page/index.html");
return modelAndView;
} }
SpringBoot不使用模板引擎直接返回html的更多相关文章
- SpringBoot日记——Thymeleaf模板引擎篇
开发通常我们都会使用模板引擎,比如:JSP.Velocity.Freemarker.Thymeleaf等等很多,那么模板引擎是干嘛用的? 模板引擎,顾名思义,是一款模板,模板中可以动态的写入一些参数, ...
- Springboot与Thymeleaf模板引擎整合基础教程(附源码)
前言 由于在开发My Blog项目时使用了大量的技术整合,针对于部分框架的使用和整合的流程没有做详细的介绍和记录,导致有些朋友用起来有些吃力,因此打算在接下来的时间里做一些基础整合的介绍,当然,可能也 ...
- 【Springboot】Springboot整合Thymeleaf模板引擎
Thymeleaf Thymeleaf是跟Velocity.FreeMarker类似的模板引擎,它可以完全替代JSP,相较与其他的模板引擎,它主要有以下几个特点: 1. Thymeleaf在有网络和无 ...
- Springboot系列:Springboot与Thymeleaf模板引擎整合基础教程(附源码)
前言 由于在开发My Blog项目时使用了大量的技术整合,针对于部分框架的使用和整合的流程没有做详细的介绍和记录,导致有些朋友用起来有些吃力,因此打算在接下来的时间里做一些基础整合的介绍,当然,可能也 ...
- SpringBoot:2.SpringBoot整合Thymeleaf模板引擎渲染web视图
在Web开发过程中,Spring Boot可以通过@RestController来返回json数据,那如何渲染Web页面?Spring Boot提供了多种默认渲染html的模板引擎,主要有以下几种: ...
- SpringBoot系列: Pebble模板引擎
===============================Java 模板引擎选择===============================SpringBoot Starter项目向导中可选的J ...
- SpringBoot集成Thymeleaf模板引擎
简单介绍 目前在JavaEE领域有几中比较常用的模板引擎,分别是Jsp.Velocity.Freemarker.Thymeleaf,对Freemark语法不是特别熟悉,不过对于前端页面渲染效率来说,j ...
- SpringBoot使用thymeleaf模板引擎
(1).添加pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...
- springboot整合Thymeleaf模板引擎
引入依赖 需要引入Spring Boot的Thymeleaf启动器依赖. <dependency> <groupId>org.springframework.boot</ ...
随机推荐
- percona-xtrabackup系列一:简单使用
1:什么是percona-xtrabackup Percona XtraBackup is an open-source hot backup utility for MySQL -based ser ...
- django之创建第8个项目-数据库配置及同步研究
1.sqlitestudio-2.1.5数据库可视化工具--百度云盘下载 2.编写C:\djangoweb\helloworld\blog\models.py文件 # Create your mode ...
- Samba共享及自动挂载测试
要求: 1.在server0服务器上安装配置samba,工作组为STAFF,共享目录/smb1, 共享名smb1,仅允许192.168.100.0/24网段中的主机访问.samba用户user1可以读 ...
- nginx深入使用
1. nginx使用命令 nginx -s stop --快速关闭Nginx,可能不保存相关信息,并迅速终止web服务. nginx -s quit --平稳关闭Nginx,保存相关信息,有安排的结束 ...
- hibernate的hql语句不支持 count(case...when ....else..)?
查看帖子:http://www.iteye.com/problems/4499 第一次这么写, 不行, 关键就是: 同是聚集函数,sum 就OK, 而 count 就不行...........后来还是 ...
- 整理打印PI值
准备锻炼背诵PI的小数,找到PI值: PI=3. 141592653589793238462643383279502884197169399375105820974944592307816406286 ...
- url 中非法字符替换,java 正则替换
url在传输时不允许的一些字符串,参考自:http://www.ietf.org/rfc/rfc1738.txt 以下字符用java正则替换为"_",一句话搞定: "{& ...
- C语言stat()函数:获取文件状态
相关函数:fstat, lstat, chmod, chown, readlink, utime 头文件:#include<sys/stat.h> #include<uninstd ...
- CentOS下yum安装mcrypt错误:No package php-mcrypt available.解决方法
错误描述: #yum install libmcrypt libmcrypt-devel mcrypt mhashSetting up Install ProcessNo package php-mc ...
- NSAttributedString 上下标---!!!!!
下面这段,亲试可用 /*将符号转换为上标*/ -(NSMutableAttributedString *)changeToSuperscriptForNumberSignWith:(NSString ...