zoukankan      html  css  js  c++  java
  • SpringBoot整合FreeMarker

    pom文件引入:

    <!-- 引入freeMarker的依赖包. -->
    
    <dependency>
    
    <groupId>org.springframework.boot</groupId>
    
    <artifactId>spring-boot-starter-freemarker</artifactId>
    
    </dependency>


    在src/main/resources/创建一个templates文件夹,后缀为*.ftl

    后台代码

         @RequestMapping("/index")
    
          public String index(Map<String, Object> map) {
    
              map.put("name","美丽");
    
                return"index";
    
          }


    前台代码
     

    <!DOCTYPE html>
    
    <html>
    
    <head lang="en">
    
    <meta charset="UTF-8" />
    
    <title></title>
    
    </head>
    
    <body>
    
            ${name}
    
    </body>
    
    </html>

    访问:http://127.0.0.1:8080/hello

  • 相关阅读:
    u Calculate e
    Elevator
    骑士走棋盘
    Number Sequence
    老鼠走迷宫
    Let the Balloon Rise
    A+B Problem II
    Three-Color Flag
    Noldbach problem
    Almost Prime
  • 原文地址:https://www.cnblogs.com/XJJD/p/10392531.html
Copyright © 2011-2022 走看看