zoukankan      html  css  js  c++  java
  • SpringBoot---基本配置

    1、首先在pom.xml添加对HTML的相关依赖

    /**
     * pom.xml文件
     */
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>**

    2、在application.yml文件添加SpringBoot相关配置

    spring:

      thymeleaf:
        prefix: classpath:/templates/

    注意:application.yml 如果是空文件,则默认视图文件存放在
    templates文件下,资源文件存放在static目录下,由于SpringBoot对jsp支持不太友好,一般使用自带的标签实现数据的赋值



    在Controller里面写跳转HTML页面方法

    @Controller  //注意这里必须为Controller
    public class HelloController {
    
        /**
         * 本地访问内容地址 :http://localhost:8080/lmycc/hello
         * @param map 传递参数
         * @return
         */
        @RequestMapping("/hello")
        public String helloHtml(HashMap<String, Object> map) {
            map.put("hello", "欢迎进入HTML页面");
            return "/index";
        }
    }
  • 相关阅读:
    spring整合Quartz
    Quartz基本使用
    hibernate框架基础描述
    POI技术实现对excel的导出
    CG-CTF CRYPTO部分wp
    CG-CTF web部分wp
    快速排序算法的c++实现
    tornado当用户输入的URL无效时转入设定的页面
    sicily 4699. 简单哈希
    unbutu下Io language的解释器安装
  • 原文地址:https://www.cnblogs.com/csguo/p/9597124.html
Copyright © 2011-2022 走看看