Java Magazine, July/August 2018
ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 28 libraries JDK 8 is a minimum requirement as of version 122 of j2html Now lets generate your first HTML code Creating a body with a heading inside is simple as shown in Listing 1 Listing 1 html body h1 Hello Java Magazine Readers That will render the HTML output shown in Listing 2 Listing 2 html body h1 Hello Java Magazine Readers h1 body html The body and h1 methods are statically imported They come from one of the most important classes of the library the TagCreator class It can be statically imported with the syntax shown in Listing 3 Listing 3 import static j2html TagCreator Lets continue with the more complex example shown in Listing 4 where I create a table with a list of employees provided as rows The page will have a stylesheet file referenced in the head section and a div that acts as a header on top of the employee table
You must have JavaScript enabled to view digital editions.