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

     

  • 相关阅读:
    Python网络爬虫与信息提取(二)—— BeautifulSoup
    Linux文件系统概述
    XML简介
    JSON数据格式
    SQL*Loader之CASE8
    SQL*Loader之CASE9
    SQL*Loader之CASE10
    SQL*Loader之CASE11
    Oracle工具之DBNEWID
    Oracle常用函数汇总
  • 原文地址:https://www.cnblogs.com/excellencesy/p/12069067.html
Copyright © 2011-2022 走看看