最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot thymeleaf的使用方法解析

 更新時(shí)間:2020年03月17日 10:45:08   作者:玉天恒  
這篇文章主要介紹了SpringBoot thymeleaf的使用方法解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

1.pom.xml添加相應(yīng)依賴(lài)

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

2.application.properties

#thymeleaf
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html; charset=utf-8
spring.thymeleaf.cache=false

3.common.xml文件,注意文件路徑

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Insert title here</title>
</head>
<body>
  <h1>my first thymeleaf.</h1>
  hello, <span th:text="${name}"></span>
</body>
</html>

4.添加TemplateController.java

package myshop.controller;

import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/*
 * 這里使用@Controller而不是@RestController
 * 還有模板文件中得去掉<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 * 所有標(biāo)簽得閉合
 * 
 * */
@Controller
@RequestMapping("/templates")
public class TemplateController {
  
  @RequestMapping("/common")
  public String Common(Map<String, Object> map)
  {
    map.put("name", "天恒");
    return "Common";
  }
}

5.添加app.java

package myshop;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App {
  
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    SpringApplication.run(App.class, args);
  }

}

6.訪(fǎng)問(wèn)路徑,完成

http://localhost:8080/templates/common

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

双流县| 镇远县| 白银市| 碌曲县| 眉山市| 昭觉县| 盘山县| 霍林郭勒市| 北票市| 太仆寺旗| 吕梁市| 化德县| 体育| 临潭县| 三台县| 安溪县| 灵石县| 新晃| 香格里拉县| 崇文区| 嘉黎县| 武平县| 长子县| 潮州市| 九寨沟县| 宜都市| 荣成市| 页游| 株洲市| 苏尼特右旗| 凤翔县| 临泉县| 门头沟区| 新化县| 乡宁县| 邵阳县| 霍林郭勒市| 青神县| 常州市| 芦山县| 镇原县|