java - 使用 Spring :eval inside hasRole

标签 java spring spring-mvc spring-security

我在 JSP 中显示属性文件中的某些属性,如下所示:

<spring:eval expression="@propertyConfigurer.getProperty('myproperty')"/>

现在,我想在 <sec:authorize access="hasRole()/> 中使用相同的属性

<sec:authorize access="hasRole('<spring:eval expression="@propertyConfigurer.getProperty('myproperty')"/>')">

这是行不通的。

最佳答案

试试这个:

<spring:eval expression="@propertyConfigurer.getProperty('myproperty')" var="myproperty"/>
<sec:authorize access="hasRole('${myproperty}')">

关于java - 使用 Spring :eval inside hasRole,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15115356/

相关文章:

java - 使用 HSQL 请求父实体时过滤一对多子实体

json - Spring 休息: HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8'

java - 如何使用带有内容的 spring boot Controller 下载 csv 文件?

带有 Spring MVC 的 Springfox Swagger2 - 404 错误

java.lang.ClassNotFoundException : com. ibm.disthub2.impl.client.SessionConfig

java - 当我在 Android java 文件中使用 Fragment,Tabspager 时出现错误

java - 按用户条件在 JSP 中渲染

java - Spring boot 2 : ConverterNotFoundException: No converter found capable of converting from type [java. time.ZonedDateTime] 输入 [java.util.Date]

java - 如何将库文件夹添加到 Eclipse?

java - 如何使用jedis集群键方法?