gpt4 book ai didi

spring-boot - Spring Boot 2.4.2 和 Thymeleaf 3.0.12 - 访问静态方法

转载 作者:行者123 更新时间:2023-12-03 15:53:47 32 4
gpt4 key购买 nike

因为我切换到 Spring Boot 2.4.2 我的 Thymeleaf 模板坏了。当我想访问 Spring Controller 中的静态成员时,出现以下错误:

Exception processing template "template_name": Instantiation of newobjects and access to static classes is forbidden in this context.


代码如下: th:text="${T(com.test).testMethod("1234")}"你有什么建议来解决这个问题吗?

最佳答案

此更改是 Thymeleaf 3.0.12 的一部分。它们通过限制访问静态代码(OGNL 中的@identifier@,SpringEL 中的 T(identifier))来限制它们的 improve restricted expression evaluation mode security。他们自己做了什么? ...“避免了新对象的实例化和对静态类的调用”,如发行说明中所述。您可以将 JAVA 调用移动到您的 Controller 中并将结果放入 View 模型中。从 Thymeleaf 模板访问此变量后。

关于spring-boot - Spring Boot 2.4.2 和 Thymeleaf 3.0.12 - 访问静态方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66048129/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com