如何使用Thymeleaf调用服务方法 [英] How to call a service method with Thymeleaf
本文介绍了如何使用Thymeleaf调用服务方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以按照以下方式在jsp中调用服务方法(例如检查授权):
As we can call service method in a jsp as follow(say to check authorization) :
<sec:authorize var="hasLicense" access="@licenseService.hasCapability('Event')"/>
使用Thymeleaf时如何调用此方法?
How can we call this method when using Thymeleaf?
我知道,我们可以按照以下步骤检查角色,但无法获得上述情况的示例:
I know, We can check role as follow but couldn't get an example for above case:
<li class="link" sec:authorize="hasRole('event')">
推荐答案
Thymeleaf允许访问在Spring Application中注册的bean 具有@beanName语法的上下文,例如:
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')}">
这篇关于如何使用Thymeleaf调用服务方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文