我注意到在我的代碼中,我可以用@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