2012-11-16 18 views
1

我有一个弹簧服务,并希望在与弹簧安全表达当前用户组合的服务来使用的方法。我看到another question on stackoverflow,导致我相信这样的事情是可能的。我使用的是spring 3.1.2。如何在Spring Security的表达式中使用Spring事务方法?

@Service("orgService") 
public class DefaultOrganizationService implements OrganizationService { 
    @Override 
    @Transactional 
    public boolean isOrgAdmin(String username) 
    { 
     return true; 
    } 
} 

然后在JSP中,我有这样的事情:

<sec:authorize access="orgService.isOrgAdmin(principal.name)"> 
    USER IS ORG ADMIN 
</sec:authorize> 

然而,当我跑我的web应用程序使用此设置,我得到

org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'orgService' cannot be found on object of type 'org.springframework.security.web.access.expression.WebSecurityExpressionRoot' 

我试着既“@orgService ...”和“orgService ......”

表情是什么,我试图做的可能,或者我需要实现一个PermissionEvaluator

+0

你有和没有'@'得到同样的错误?请发布两个。如果没有'@',你发布的错误看起来很好。我很好奇'@ orgService ..'的错误信息。' –

+0

事实证明,我对“@”(与委托人有关)有不同的错误。使用“@”事实上确实让春天的安全性认识的bean的名字。 – Jay

回答

0

@orgService应该工作,为春季安全起价Version 3.1.0.RC2

[SEC-1723] - Support use of bean names in expressions via @beanName notation


I'm using spring 3.1.2.

我认为你使用的是旧版本的Spring Security的,不是Spring。

相关问题