Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


Spring Boot Thymeleaf 获取 Bean 等容器中的对象

Spring Boot Thymeleaf 大约 328 字

需求

获取@Bean@Component@ConfigurationSpring自动注入到的容器对象。

${@}

使用${@}语法,获取容器中的对象。

其中,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

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批