【问题标题】:Is there a way to provide an attribute to all models in Spring?有没有办法为 Spring 中的所有模型提供一个属性?
【发布时间】:2023-01-11 12:25:43
【问题描述】:

Thymeleaf 在版本 3.1 (https://www.thymeleaf.org/doc/articles/thymeleaf31whatsnew.html) 中删除了 #session#httpServletRequest 等模板表达式。

我们在相对较大的应用程序中经常使用它们。我编写了一个拦截器来在每次请求时填充这些属性,因为我不想将它们添加到每个需要的控制器中(如迁移指南中所述)。

有人知道实现这一目标的更好方法吗?

【问题讨论】:

    标签: java spring spring-mvc thymeleaf


    【解决方案1】:

    Spring framework documentations. 中定义的早期方法相比,这已经是在每个请求中填充属性的最佳方法

    【讨论】:

      猜你喜欢
      • 2021-09-06
      • 2022-08-23
      • 1970-01-01
      • 2021-05-09
      • 2016-07-18
      • 2023-03-23
      • 2012-10-03
      • 2010-11-23
      • 1970-01-01
      相关资源
      最近更新 更多