Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot & Thymeleaf with XML Templates

I have a Spring Boot application with a controller that returns a ModelAndView and Thymeleaf to render templates, where the templates live in /src/main/resources/templates/*.html

This works fine, but How can I configure Spring and/or Thymeleaf to look for xml files instead of html?

If it helps, I'm using Gradle with the org.springframework.boot:spring-boot-starter-web dependency to set things up. I am currently running the server using a class with a main method.

like image 490
user605331 Avatar asked Sep 17 '25 08:09

user605331


1 Answers

After trying and failing at various bean defs for viewResolver and related things, I finally got this working with a change to my application.yaml file:

spring:
  thymeleaf:
    suffix: .xml
    content-type: text/xml

For those reading this later, you can do similar with your application.properties file (with dot notation in place of the yaml indentation).

like image 168
user605331 Avatar answered Sep 19 '25 03:09

user605331