Springboot项目搭建(2)-整合静态文件
1,引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2,添加静态文件

3,修改配置文件:在application.properties中添加:
#静态资源整合
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ ,swagger-ui.html,druid/index.html #thymeleaf 模板配置 cache 缓存开发时该禁止
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
4,添加controller
package com.googosoft.controller.test; import java.util.Map; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class TestController { @RequestMapping("index")
public String index(Map<String,Object> params){
return "/index.html";
} @RequestMapping("log")
public String log(Map<String,Object> params){
return "/log.html";
} }
4,测试


Springboot项目搭建(2)-整合静态文件的更多相关文章
- SpringBoot 项目搭建(详细介绍+案例源码)
SpringBoot 项目搭建 SpringBoot 项目整合源码 SpringBoot 项目整合 一.项目准备 1.1 快速创建 SpringBoot 项目 1.2 标准项目结构图如下 1.3 添加 ...
- SpringBoot之入门教程-SpringBoot项目搭建
SpringBoot大大的简化了Spring的配置,把Spring从配置炼狱中解救出来了,以前天天配置Spring和Mybatis,Springmvc,Hibernate等整合在一起,感觉用起来还是挺 ...
- django 项目运行时static静态文件不能加载问题处理
一.首先检查网页中的加载路径是否正确,如果和文件所在路径不一致,就把html改下路径 二.加载路径和文件实际路径一致,看下配置文件: STATIC_URL = '/static/'STATIC_ROO ...
- JAVA - SpringBoot项目引用generator生成 Mybatis文件
JAVA - SpringBoot项目引用generator生成 Mybatis文件 在spring官网https://start.spring.io/自动生成springboot项目,这里选择项目 ...
- 用Express、MySQL搭建项目(接口以及静态文件获取、文件上传等)
一.简介 本文将主要基于node.js使用express框架搭建一个后台环境,包括如何自定义项目目录.所用依赖以及中间件.路由以及模板引擎.接口数据获取以及文件上传等内容. 二.后台环境搭建 1.新建 ...
- SpringMVC-Spring-Hibernate项目搭建之三-- freemarker & 静态资源整合
一. 前段目录结构如下架构如下: 二. freemarker文件配置 在 web.xml 文件中指定 spring 配置文件的位置 三. 配置springmvc-servlet.xml文件 1)配置自 ...
- SpringBoot项目搭建 + Jwt登录
临时接了一个小项目,有需要搭一个小项目,简单记录一下项目搭建过程以及整合登录功能. 1.首先拿到的是一个码云地址,里面是一个空的文件夹,只有一个 2. 拿到HTTPS码云项目地址链接,在IDEA中cl ...
- SpringBoot项目搭建与打包
一.环境准备 本地java环境jdk1.8 Maven版本3.5.2 IDE工具idea2017 二.SpringBoot微服务搭建 1.点击File >> New >> Pr ...
- springboot系列二、springboot项目搭建
一.官网快速构建 1.maven构建项目 1.访问http://start.spring.io/ 2.选择构建工具Maven Project.Spring Boot版本2.1.1以及一些工程基本信息, ...
随机推荐
- 什么是kafka,怎么使用? (2) - 内含zookeeper等
zookeeper依赖于java https://baike.baidu.com/item/yum/2835771?fr=aladdin http://yum.baseurl.org/ 去yum官网下 ...
- C# ODP.Net oracle数据库操作 支持不安装客户端
下载: http://download.oracle.com/otn/other/ole-oo4o/ODTwithODAC1110720.zip?AuthParam=1414811820_e61f2f ...
- LitElement(四)属性
1.概述 LitElement管理您声明的属性及其对应的属性.默认情况下,LitElement将: 确保在任何声明的属性更改时进行元素更新. 捕获已声明属性的实例值.在浏览器注册自定义元素定义之前设置 ...
- sendmail邮件服务器
安装sendmail之前 我们要先搭建一个DNS服务器用来解析邮件 下图是配置好的DNS正向解析记录和反向解析记录 正向 反向 DNS配置好之后我们就来安装sendmail服务 然后再安装sendma ...
- centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not foundc
现象: 在centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not found [明明已经安装了,为什么提示不存在呢?] 原因: 在 ...
- kali2018.4 下载地址
https://www.linuxidc.com/Linux/2018-10/155088.htm
- 伪数组变数组 js
语法糖:简单的说:用语法糖就是把复杂(有助于让我们理解代码含义)的代码,让我们可以简单的敲出来.这种语法对语言本身功能来说没有什么影响,只是为了方便程序员的开发,提高开发效率 方法一: var a=d ...
- 问题 D: 家庭问题
问题 D: 家庭问题 时间限制: 1 Sec 内存限制: 128 MB[命题人:admin] 题目描述 有n个人,编号为1,2,……n,另外还知道存在K个关系.一个关系的表达为二元组(α,β)形式, ...
- [Luogu]小Z的AK计划
Description Luogu2107 Solution 一开始打了一个60分的暴力DP,结果一分都没得--本地调了好久才发现是没开long long. 由于我的DP方程没有任何性质,就是一个01 ...
- Nearest Interesting Number
Polycarp knows that if the sum of the digits of a number is divisible by 33, then the number itself ...