评估字符串阵列的弹簧表达式的异常

发布于 2025-02-01 12:19:30 字数 518 浏览 2 评论 0原文

而在Spring Boot< = 2.4.3以下摘要工作正常。

<div class="link-red ddmenu" th:with="urls=${new String[]{'/'}}"
    th:classappend="${#arrays.contains(urls, #httpServletRequest.getRequestURI()) ? 'selected' : ''}">
    <a href="/" th:href="@{/}"> <i class="fa fas fa-home"></i>Home
    </a>
</div>

但是在升级到2.7.0之后,我得到了这个解析例外。我该怎么办?

Exception evaluating SpringEL expression: "new String[]{'/'}"

还是此休息时间的任何相关信息,可在任何百里美的官方网站上可用?

While at spring boot <= 2.4.3 the below snippet worked fine.

<div class="link-red ddmenu" th:with="urls=${new String[]{'/'}}"
    th:classappend="${#arrays.contains(urls, #httpServletRequest.getRequestURI()) ? 'selected' : ''}">
    <a href="/" th:href="@{/}"> <i class="fa fas fa-home"></i>Home
    </a>
</div>

But after upgrading to 2.7.0, I am getting this parsing exception. What should I do to fix it?

Exception evaluating SpringEL expression: "new String[]{'/'}"

Or any related information for this break, available on any Thymeleaf's official site?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

留蓝 2025-02-08 12:19:30

有趣的是,如果您不断向下看堆栈轨道,您会在底部发现此错误:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1005E: Type cannot be found 'String'

如果我将表达式更改为:

th:with="urls=${new java.lang.String[]{'/'}}"

一切都对我有效(用Spring Boot Starter 2.6.7进行了测试)。

Interestingly enough, if you keep looking down the stack track you find this error at the bottom:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1005E: Type cannot be found 'String'

If I change the expression to:

th:with="urls=${new java.lang.String[]{'/'}}"

Everything works again for me (tested with Spring Boot starter 2.6.7).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文