Using Apache FreeMarker for the view
In this section, it will be explained in detail what a template engine is, and then we will talk about how to use Spring Apache FreeMarker to implement the view presentation.
Understanding template engines
Standard Java Jakarta Enterprise Edition (Jakarta EE) applications useJavaServer Pages (JSPs) to generate presentation views for the end user. JSP is a mature technology that enables the use of embedded Java code as well as JavaServer Pages Standard Tag Library (JSTL) elements, which will, in turn, execute Java code, which can generate presentation views. All JSPs are eventually compiled as a Servlet
.
But mixing these Java codes and presentation-specific codes (HTML, CSS, and many more) is cumbersome and makes the separation of concerns difficult. Furthermore, presentation views mad using plain JSPs are difficult to modify and be maintained by UI engineers. That is where UI template engines are useful.
Template engines provide an easy way of decoupling...