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

     

  • 相关阅读:
    提前期分类
    物料属性,MRP/MPS属性
    ASP.NET刷新页面的一些方法
    Nothing 和 Is
    三层架构与MVC
    ADO.NET
    软件工程之数据流程图(DFD Data Flow Diagram)
    VB.NET小结
    推荐开发人员看的具有影响力的书籍
    C++考试
  • 原文地址:https://www.cnblogs.com/excellencesy/p/12069067.html
Copyright © 2020-2023  润新知