I have the following project structure in my Spring boot app, in which I want to use Thymeleaf but the spring-boot cannot find my template directory and is showing warning Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration) PS: I am using @EnableAutoConfiguration In my controller code I am doing something like: and index.html
Tag: thymeleaf
Spring boot and Thymeleaf – Hot swap templates and resources once again
I tried all tips and tricks that I found here and in docs, but still no luck. I have Spring webapp with Thymeleaf. Resources and templates are not reloaded when I call update in IDEA (it says nothing to reload). I can then press ctrl+f5 in a browser like crazy, changes are just not there. Everything is configured in one
Thymeleaf Neither BindingResult nor plain target object for bean name ‘person’ available as request attribute
From what I can tell this is set up correctly but I am getting the following error: Form Person.java Controller I looked at Spring-boot and Thmeleaf setup and it looks like my setup is identical. ——————— Update 1 ———————– I have changed my post method to include BindingResult with no success. Answer You forgot to add BindingResult after your @ModelAttribute
Serving HTML pages in a Spring Boot application
I have a Spring Boot Application. I am trying to pass a variable to a HTML page but unfortunately I cannot seem to do it, on application start nothing is rendered except the static text: “WORLD”. My controller is as below: And my index.html: I was looking for an answer and I found these articles: How to serve .html files
How to send email with inline image using ThymeLeaf
I’m trying to send an email with an inline image using ThymeLeaf and Spring, but so far no success. The email sends, but the inline image won’t show in the email. The project is not web-based (not a website), but is a desktop stand-alone, not mobile This is how I get the image file: My service class: The HTML: Answer
SpringBoot with Thymeleaf – css not found
First to say is that I’ve been searching for a solution for a while now and I’m quite desperate now. I cannot get the css file to be accessible from html page when run by Spring Boot. html.file Application.java folder structure: I’ve tried putting the css folder into a static folder and/or removing the addResourcesHandlers, referencing to the css by
Thymeleaf: how to use conditionals to dynamically add/remove a CSS class
By using Thymeleaf as template engine, is it possible to add/remove dynamically a CSS class to/from a simple div with the th:if clause? Normally, I could use the conditional clause as follows: We will be creating a link to the lorem ipsum page, but only if condition clause is true. I’m looking for something different: I’d like the block to
How to show localization messages with parameters in Spring 3 / Thymeleaf
I’m using Spring 3 and Thymeleaf to make some webpages and I am lost as for how to show messages like this: welcome.message=Hello {0}, welcome! and then replace {0} with the user name inside thymeleaf tags: I’m not even sure if {0} is the right syntax for the bundle message. Answer You can use where some.attribute would be the value
How to pass two objects to use in a form using thymeleaf?
My problem is the following : I’ve 2 differents objects that I’ve to fill from a single form. With 1 object, I simply do in the newFoo.html: and in the FooController: Let’s say I’ve an other object bar with a “status” variable in it. How can I do to pass that object so I can submit the input within the
Thymeleaf: how to get URL attribute value
I can’t find any solution for getting attribute from URL using Thymeleaf. For example, for URL: I need to get “error” attribute value. Also I’m using SpringMVC, if it could be helpful. Answer After some investigation I found that it was Spring EL issue actually. So complete answer with null checking is: