【发布时间】:2019-03-15 23:16:40
【问题描述】:
我正在尝试在脚本标签中发送一个参数,如下所示:
<script th:src="@{/js/myScript.js(arg0=${value})}"></script>
其中 value 是以下结果:hasAuthority('USER')
所以,我尝试了这个:
<script th:src="@{/js/myScript.js(arg0=${hasAuthority('USER')})}"></script>
但这不起作用:
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "hasAuthority('USER')" (template: "groups" - line 61, col 9)
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method hasAuthority(java.lang.String) cannot be found on org.thymeleaf.spring4.expression.SPELContextMapWrapper type
我之前用过这个函数来显示没有问题的 div:
<li sec:authorize="${hasAuthority('ADMIN')}">
【问题讨论】:
标签: java spring-mvc thymeleaf