【问题标题】:EL in <sec:authorize> access attribute<sec:authorize> 访问属性中的 EL
【发布时间】:2011-12-15 04:28:04
【问题描述】:

不能在访问属性中使用EL吗?我不喜欢在标签中硬编码角色名称,而是想使用一个常量。但它抛出一个异常说:

org.apache.jasper.JasperException: abc.jsp(19,4) According to TLD or
attribute direc tive in tag file, attribute access does not accept
any expressions

Here is what I have in jsp(using unstandard taglib for constants):

<%@taglib uri="http://jakarta.apache.org/taglibs/unstandard-1.0" prefix="un"%>
<un:useConstants className="com.xxx.PrivilegeConstants" var="privilege" />
.....

<sec:authorize access="hasRole('${privilege.USER_ROLE}')">  // throwing ex here
   security content here....
</sec:authorize>    

Is there any other alternative? Thanks in advance...

【问题讨论】:

    标签: spring spring-mvc spring-security


    【解决方案1】:

    看起来支持是后来添加的。请参阅 JIRA here。我猜使用添加此支持的版本应该可以工作。

    【讨论】:

    • 非常感谢,看起来它已在 3.1 中修复,但我使用的是 Spring Security 3.0.5。有趣的是,还有另一个相似的 JIRA here,但它在 3.0.3 中被提及为已修复,不确定它在 3.0.5 中不起作用!!
    • 现在我用丑陋的脚本修复了它:( ...在此处显示内容....
    猜你喜欢
    • 2018-06-05
    • 2014-06-01
    • 2019-05-07
    • 1970-01-01
    • 2013-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-15
    相关资源
    最近更新 更多