gpt4 book ai didi

spring - 如何使用Thymeleaf调用服务方法

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

由于我们可以按以下方式在jsp中调用service方法(比如检查授权):

<sec:authorize var="hasLicense" access="@licenseService.hasCapability('Event')"/>

使用Thymeleaf时如何调用此方法?

我知道,我们可以按以下方式检查角色,但无法获得上述情况的示例:
<li class="link" sec:authorize="hasRole('event')">

最佳答案

Thymeleaf allows accessing beans registered at the Spring Application Context with the @beanName syntax, for example:

<div th:text="${@urlService.getApplicationUrl()}">...</div>


http://www.thymeleaf.org/doc/articles/springmvcaccessdata.html

所以这应该工作:
<li class="link" sec:authorize="${@licenseService.hasCapability('Event')}">

关于spring - 如何使用Thymeleaf调用服务方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43841458/

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