Java Magazine, July/August 2018
ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 27 libraries j2html is a small but powerful library that enables you to generate type safe HTML code with its fluent API The idea behind it is to allow developers to write declarative Java code with a one to one mapping to HTML code Note that j2html is not a templating engine but it provides an alternative way to dynamically create and reuse UI code in a type safe way It was created and is actively maintained by David Åse In this article I show you the bits and pieces you need to get started with the library and then move on to advanced use cases The source for the examples is available for download Getting Started You can obtain the latest version of j2html from Mavens Central Repository with the following dependency definition The latest available version at the time of this writing is 130 dependency groupId com j2html groupId artifactId j2html artifactId version 130 version dependency If you are using Gradle the dependency can be added as follows compile com j2html j2html 130 j2html An HTML5 Generator Library Easily write small dynamically generated web applications and get the benefits of Javas type safety and tools ecosystem MERT ÇALIS KAN
You must have JavaScript enabled to view digital editions.