您可以执行以下操作:
public class Test implements AuthenticationSuccessHandler { public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { Set<String> roles = AuthorityUtils.authorityListToSet(authentication.getAuthorities()); if (roles.contains("ROLE_USER") { response.sendRedirect("/userpage"); } }}在XML配置中添加以下内容:
<bean id="authenticationFilter" > <!-- There might be more properties here, depending on your auth filter!! --> <property name="authenticationSuccessHandler" ref="successHandler" /></bean><bean id="successHandler" />



