春季靴子Thymeleaf与XML模板

编程入门 行业动态 更新时间:2024-10-25 00:28:17
本文介绍了春季靴子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模板

本文发布于:2023-10-12 01:26:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483362.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:靴子   春季   模板   Thymeleaf   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!