zoukankan      html  css  js  c++  java
  • spriingboot使用thymeleaf

    1 添加jar包

    <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>

    2 配置文件

    server.port=8090
    spring.thymeleaf.prefix=classpath:/templates/
    spring.thymeleaf.suffix=.html
    spring.thymeleaf.mode=HTML5
    spring.thymeleaf.encoding=UTF-8
    spring.thymeleaf.cache=false
    spring.resources.chain.strategy.content.enabled=true
    spring.resources.chain.strategy.content.paths=/**

    3 在templates下新建hello.html

    4 新建测试TestController.java

    @Controller
    public class TestController {
        @RequestMapping("/hello")
        public String toHello() {
            return "hello";
        }
    }

    5 访问页面

     6 完成

  • 相关阅读:
    multi-task learning
    代码杂谈-python函数
    代码杂谈-or符号
    安装maven
    zsh
    mint linux的几个问题
    [软件] Omnigraffle
    无梯度优化算法
    根据pdf文件获取标题等信息
    计算广告-GD广告
  • 原文地址:https://www.cnblogs.com/syscn/p/9950742.html
Copyright © 2011-2022 走看看