How to call a service method with Thymeleaf
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
So this should work:
<li class="link" sec:authorize="${@licenseService.hasCapability('Event')}">
For you to call your service methods from your Thymeleaf
template you need to add that service into your model like so
@Controllerpublic class PageController { @Autowired LicenseService licenseService; @RequestMapping("/yourPage") public String getYourPage(Model model) { model.addAttribute("licenseService", licenseService); return "yourPage.html"; }}
After that you are good to use licenseService
in yourPage.html
.
<div th:if="${licenseService.verifyLicense() == true}"> <p> License verified </p></div>