国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

SpringBoot使用Thymeleaf模板引擎訪問靜態html的過程

瀏覽:4日期:2023-04-15 18:49:15

最近要做一個java web項目,因為頁面不是很多,所以就沒有前后端分離,前后端寫在一起,這時候就用到thymeleaf了,以下是不動腦式的傻瓜教程。。。。。

一:創建spring boot的web項目,過程略;

二:依賴如下:

<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> <version>2.1.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions><exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId></exclusion> </exclusions> </dependency>

三:配置文件:application.properties

#端口號server.port=8099# 配置#thymeleafspring.thymeleaf.cache=falsespring.thymeleaf.prefix=classpath:/templates/spring.thymeleaf.check-template-location=truespring.thymeleaf.suffix=.htmlspring.thymeleaf.encoding=UTF-8spring.thymeleaf.servlet.content-type=text/htmlspring.thymeleaf.mode=HTML

四:項目的templates文件夾下新建頁面success.html,如下

SpringBoot使用Thymeleaf模板引擎訪問靜態html的過程

五:controller

import org.springframework.stereotype.Controller;import org.springframework.ui.ModelMap;import org.springframework.web.bind.annotation.RequestMapping; /** * @author liuhongyang * @2020/10/20 14:35 * 文件說明: */@Controllerpublic class FirstTestController { @RequestMapping(value = 'hello') public String hello(ModelMap modelMap) { modelMap.put('hei', 'thymeleaf'); return 'success'; }}

六:訪問如下,完成

SpringBoot使用Thymeleaf模板引擎訪問靜態html的過程

到此這篇關于SpringBoot使用Thymeleaf模板引擎訪問靜態html的過程的文章就介紹到這了,更多相關SpringBoot Thymeleaf模板訪問靜態html內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 印江| 四川省| 仲巴县| 西盟| 雅安市| 云梦县| 安庆市| 常山县| 麻阳| 定州市| 靖安县| 犍为县| 九台市| 景泰县| 鸡西市| 广东省| 长汀县| 陕西省| 彩票| 广东省| 珲春市| 许昌县| 德惠市| 托里县| 沾益县| 太仓市| 乳源| 溧水县| 昆山市| 青岛市| 新乡县| 宽城| 平阳县| 乐山市| 农安县| 玉屏| 炉霍县| 威远县| 黄冈市| 嵊州市| 渭源县|