zoukankan      html  css  js  c++  java
  • Springboot项目搭建(3)-整合静态文件

    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,测试

     

  • 相关阅读:
    poj 1743 Musical Theme 后缀数组
    poj 1743 Musical Theme 后缀数组
    cf 432D Prefixes and Suffixes kmp
    cf 432D Prefixes and Suffixes kmp
    hdu Data Structure? 线段树
    关于position和anchorPoint之间的关系
    ios POST 信息
    CALayers的代码示例
    CALayers详解
    ios中得sqlite使用基础
  • 原文地址:https://www.cnblogs.com/excellencesy/p/12069067.html
Copyright © 2011-2022 走看看