我注意到在我的代码中,我可以用@Secured(“ROLE_ADMIN”)和@RolesAllowed(“ROLE_ADMIN”)成功注释服务类(@Service)上的方法。有用。虽然,当我将相同的注释移动到控制器类(@Controller)时,只有@Secured被激活,而@RolesAllowed被忽略。我配置我的Spring Security注释不一致?
<security:global-method-security
jsr250-annotations="enabled"
secured-annotations="enabled"/>
根的applicationContext为什么不@RollesAllowed适用于控制器类,而@Secured是什么?
问题你为什么同时使用? – Woot4Moo
以便我学会如何使用它们,然后可以有更多的教育意见,我会选择。你知道为什么我看到问题中解释的行为? – Pomario
我认为这是因为您正在尝试使用两组相似但不相同的注释。据我记得'@ RolesAllowed'是纯粹的Spring做法,'@ Secured'特别与Spring Security绑定。 – Woot4Moo