4. Template Engine - Apache FreeMarker
Contents
FreeMarker is a java-based template engine, commonly used to generate dynamic mvc architecture web pages.
Add FreeMarker Dependency
Add FreeMarker dependency into pom.xml:
|
|
Add Freemarker Properties
Add FreeMarker properties into application.properties:
|
|
Create Freemarker Template
- Right click resources/templates directory: New > File
- Fill in: hello-freemarker.ftl
- Click “OK” button

Copy and paste the following content into hello-freemarker.ftl:
|
|
Create Freemarker Controller
- Right click co.dongchen.shop.controller directory: New > Java Class
- Fill in: FreeMarkerController
- Click “OK” button

Copy and paste the following content into FreeMarkerController.java:
|
|
Verify
Run the App
|
|

Choose the correspondent option and press enter.
View FreeMarker Template Page in the Browser
|
|

References Apache FreeMarker
Author Dong Chen
LastMod Sat Apr 27 2019