我有一个带有控制器的Spring Boot应用程序,该控制器返回ModelAndView和Thymeleaf来渲染模板,其中的模板位于/ src / main / resources / templates / *。html
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
这很好用,但是如何配置Spring和/或Thymeleaf来查找xml文件而不是html?
This works fine, but How can I configure Spring and/or Thymeleaf to look for xml files instead of html?
如果有帮助,我正在使用与org.springframework.boot:spring-boot-starter-web依赖项建立关系。我目前正在使用带有main方法的类来运行服务器。
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.
推荐答案尝试并失败了viewResolver和Bean的各种def后,相关的事情,我终于在我的application.yaml文件中进行了更改:
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稍后再阅读,您可以对application.properties文件执行类似操作(用点符号代替yaml缩进)。
For those reading this later, you can do similar with your application.properties file (with dot notation in place of the yaml indentation).
更多推荐
春季靴子Thymeleaf与XML模板
发布评论