私は答えを探しましたが、それを見つけられませんでした。私がspring-security.xmlの<form-login>
の中に<intercept-url pattern="/test*" access="ROLE_USER" />
を追加すると、すべてが予想通りに機能します。この場合、両方のジョンには、まあ@RolesAllowedは機能しません
<http auto-config="true">
<form-login login-page="/login.html"
default-target-url="/welcome.html"
authentication-failure-url="/loginfailed.html" />
<logout logout-success-url="/logout.html" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="john" password="doe" authorities="ROLE_ADMIN" />
<user name="jane" password="doe" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<global-method-security secured-annotations="enabled" jsr250-annotations="enabled" />
:春のsecurity.xmlは、この(jsr250-注釈が有効になっている)ように見える場合
@RolesAllowed("ROLE_ADMIN")
@RequestMapping(value="/test", method = RequestMethod.GET)
public String test() {
return "test";
}
をそして:しかし、私は@RolesAllowed("ROLE_ADMIN")
は、メソッドのために行動したい場合Janeはテストページにアクセスできます。私は何か基本的なことを逃したと思う、ヘルプは高く評価されるだろう。
ですか?かなり面白いです。私が自分の守備で言うことができるのは、私がロシア人だということだけです。 –