View Resolvers with Spring Boot

De My Limbic Wiki
Aller à : navigation, rechercher

JSP

JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun Microsystems,[1] JSP is similar to PHP and ASP, but it uses the Java programming language.

To deploy and run JavaServer Pages, a compatible web server with a servlet container, such as Apache Tomcat or Jetty, is required.

<!DOCTYPE html>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html lang="en">
<body>
    <div>
        <div>
            <h1>Spring Boot JSP Example</h1>
            <h2>Hello ${message}</h2>
             
            Click on this <strong><a href="next">link</a></strong> to visit another page.
        </div>
    </div>
</body>
</html>

Thymeleaf

https://www.thymeleaf.org/

Allow Backend and Frontend developers to communicate throug text inside HTML repalaced at the template rendering with the text contained in the "text" attribute

<!-- '''Here a sample''' -->
<p th:utext="#{home.welcome(${session.user.name})}">
   Welcome to our grocery store, Sebastian Pepper!
</p>

Apache FreeMarker

FreeMarker is a free Java-based template engine, originally focusing on dynamic web page generation with MVC software architecture. However, it is a general purpose template engine, with no dependency on servlets or HTTP or HTML, and is thus often used for generating source code, configuration files or e-mails. https://velocity.apache.org/

<#assign name = "${article.getName()}">
<#if name?starts_with("https")>
    <a href="http://www.learn.com</a>
    <#else>
    <a href="http://www.vogella.com/tutorials/${name}/article.html">${title}</a>
</#if>

Apache Velocity

https://velocity.apache.org/

<html>
    <head>
        <title>Spring & Velocity</title>  
    </head>
    <body>
        <div>
            #parse("/WEB-INF/fragments/header.vm")
        </div>  
        <div>
            <!-- View index.vm is inserted here -->
            $screen_content
        </div>  
        <div>
            #parse("/WEB-INF/fragments/footer.vm")
        </div>
    </body>
</html>
<!------------------------------------------------->
<h1>Index</h1>
  
<h2>Tutorials list</h2>
<table border="1">
    <tr>
        <th>Tutorial Id</th>
        <th>Tutorial Title</th>
        <th>Tutorial Description</th>
        <th>Tutorial Author</th>
    </tr>
    #foreach($tut in $tutorials)
    <tr>
        <td>$tut.tutId</td>
        <td>$tut.title</td>
        <td>$tut.description</td>
        <td>$tut.author</td>
    </tr>
    #end
</table>

Pebble

https://pebbletemplates.io/

<html>
<head>
	<title>{% block title %}My Website{% endblock %}</title>
</head>
<body>
	<div id="content">
		{% block content %}{% endblock %}
	</div>
	<div id="footer">
		{% block footer %}
			Copyright 2018
		{% endblock %}
	</div>
</body>
</html>