Spring Boot Thymeleaf 获取 Bean 等容器中的对象
Spring Boot Thymeleaf 大约 328 字需求
获取@Bean
、@Component
、@Configuration
等Spring
自动注入到的容器对象。
${@}
使用${@}
语法,获取容器中的对象。
其中,portal
对象是配置类。
<title th:text="${@portal.name}"></title>
Portal
代码
@Setter
@Getter
@Component // 为了在 Thymeleaf 中获取 Bean 对象时名称可以短一些
@ConfigurationProperties(prefix = "preferences.portal")
public class Portal {
private String name;
}
阅读 90 · 发布于 2023-08-23
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称: