一、在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的更多相关文章

  1. SpringBoot日记——Thymeleaf模板引擎篇

    开发通常我们都会使用模板引擎,比如:JSP.Velocity.Freemarker.Thymeleaf等等很多,那么模板引擎是干嘛用的? 模板引擎,顾名思义,是一款模板,模板中可以动态的写入一些参数, ...

  2. Springboot与Thymeleaf模板引擎整合基础教程(附源码)

    前言 由于在开发My Blog项目时使用了大量的技术整合,针对于部分框架的使用和整合的流程没有做详细的介绍和记录,导致有些朋友用起来有些吃力,因此打算在接下来的时间里做一些基础整合的介绍,当然,可能也 ...

  3. 【Springboot】Springboot整合Thymeleaf模板引擎

    Thymeleaf Thymeleaf是跟Velocity.FreeMarker类似的模板引擎,它可以完全替代JSP,相较与其他的模板引擎,它主要有以下几个特点: 1. Thymeleaf在有网络和无 ...

  4. Springboot系列:Springboot与Thymeleaf模板引擎整合基础教程(附源码)

    前言 由于在开发My Blog项目时使用了大量的技术整合,针对于部分框架的使用和整合的流程没有做详细的介绍和记录,导致有些朋友用起来有些吃力,因此打算在接下来的时间里做一些基础整合的介绍,当然,可能也 ...

  5. SpringBoot:2.SpringBoot整合Thymeleaf模板引擎渲染web视图

    在Web开发过程中,Spring Boot可以通过@RestController来返回json数据,那如何渲染Web页面?Spring Boot提供了多种默认渲染html的模板引擎,主要有以下几种: ...

  6. SpringBoot系列: Pebble模板引擎

    ===============================Java 模板引擎选择===============================SpringBoot Starter项目向导中可选的J ...

  7. SpringBoot集成Thymeleaf模板引擎

    简单介绍 目前在JavaEE领域有几中比较常用的模板引擎,分别是Jsp.Velocity.Freemarker.Thymeleaf,对Freemark语法不是特别熟悉,不过对于前端页面渲染效率来说,j ...

  8. SpringBoot使用thymeleaf模板引擎

    (1).添加pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...

  9. springboot整合Thymeleaf模板引擎

    引入依赖 需要引入Spring Boot的Thymeleaf启动器依赖. <dependency> <groupId>org.springframework.boot</ ...

随机推荐

  1. java 文件复制

      java实现文件复制 CreateTime--2017年9月7日15:04:48 Author:Marydon 1.需求 根据原文件复制一份到指定位置 2.代码实现 需要导入: import ja ...

  2. 〖Linux〗Ubuntu中使用KVM安装虚拟机

    1. 安装软件: sudo apt-get install libvirt0 libvirt-bin libvirt-dev virt-manager qemu-system 2. 配置网桥: # i ...

  3. 〖Linux〗git push orgin master不能解析域名的解决方法

    错误信息: $ git push origin master ssh: Could not resolve hostname bitbucket.org: Name or service not kn ...

  4. Ubuntu16.04下的stm32环境配置

    安装stlink 必须安装libusb-1.0-0-dev, 其他安装不起作用 -dev git clone https://github.com/texane/stlink.git cd stlin ...

  5. 下载完整版Chrome离线安装文件的官方地址

    只在自己账号下安装Download Google Chrome Standalone Offline Installer (32-bit)  http://www.google.com/chrome/ ...

  6. Dockerfile 构建前端nginx应用并用shell脚本实现jenkins自动构建

    Dockerfile 文件构建docker镜像 FROM centos MAINTAINER zh********h.cn RUN rm -f /etc/nginx/nginx.conf COPY n ...

  7. (原)ubuntu中安装tensorflow

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6592052.html 参考网址: https://www.tensorflow.org/install ...

  8. Ubuntu 12.04安装VMware Workstation8.0.3

    2012-06-18 12:52   Ubuntu安装VMware Workstation8.0.3   由于使用Ubuntu的人比较少,网上关于Ubuntu的资料也很少,笔者在安装VMware Wo ...

  9. UCCI协议[转]

    象棋百科全书 中国象棋电脑应用规范(五) 中国象棋通用引擎协议 版本:3.0 象棋百科全书网 (webmaster@xqbase.com) 2004年12月初稿,2007年11月修订 一.概述 中国象 ...

  10. 下载历史版本App

    文/timhbw(简书作者)原文链接:http://www.jianshu.com/p/edfed1b1822c著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 1.软件准备 [必备]C ...