In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to use FreeMarker in SpringBoot". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use FreeMarker in SpringBoot" can help you solve the problem.
FreeMarker introduction
Apache FreeMarker? Is a template engine: a Java library for generating text output from templates and change data (HTML web pages, email, configuration files, source code, etc.). Templates are written in FreeMarker template language (FTL), which is a simple specialized language (unlike a complete programming language like PHP). Typically, you use a common programming language, such as Java, to prepare data (publish database queries, do business calculations). Apache FreeMarker then uses a template to display the prepared data. In the template, you will focus on how to render the data, while outside the template, you will focus on the data to be rendered.
Thymeleaf is officially recommended by SpringBoot. Since I am relatively familiar with FreeMarker, I will first introduce how to use the current front-end page of FreeMarker in SpringBoot.
Steps for SpringBoot to use FreeMarker
The first step is in pom.xml? The specific code for introducing spring-boot-starter-freemarker dependency in is as follows:
Org.springframework.boot spring-boot-starter-freemarker
The second step is to create a test directory by templates under resources and create a new freemarkDemo.ftl content as follows:
${msg}
? The third step is to create a Controller that accesses the freemarkDemo.ftl.
@ Controller@RequestMapping ("/ hello") public class HelloWorldController {@ RequestMapping ("/ test") public String test (Model model) {model.addAttribute ("msg", "SpringBoot With Freemark helloworld!"); return "test/helloworld";}} Test
Enter the URL: http://localhost:8080/sbe/hello/test? of the Controller that accesses the FreeMarker page in the browser. Carry on the test, the test result is as follows:
This is the end of the introduction to "how to use FreeMarker in SpringBoot". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.