春季靴子Thymeleaf与XML模板 [英] Spring Boot & Thymeleaf with XML Templates

查看:75
本文介绍了春季靴子Thymeleaf与XML模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有控制器的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模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆