javathymeleafprogram-entry-pointtemplate-engine

How to use Thymeleaf to make only a simple Java app (without Spring)


I'm following the official Thymeleaf tutorial on its website and I'm currently on the section Executing the template engine.

From what I understood, I should already be able to run the app coded so far, but I absolutely don't see how to run it. There is no main(String[] args) method to run at all.

I tried searching for other tutorials but they all use Spring which is not what I'm looking for right now.

Anyone knows where I should insert a main(String[] args) method to run this Thymeleaf app and view my HTML template? I don't understand where the entry point is or should be.

I apologize in advance if this question sounds dumb and thanks for your future replies.


Edit:

Until now, when following the tutorial I wrote 3 Java files:

So I thought of writing a main method like so: Main class containing main(String[] args) method

But I don't see how to correctly instantiate the servletContext and I'm not even sure if everything will work out once this is done.


Solution

  • You can create your main method in any class that you created and then create Thymeleaf objects that you need. This might help