小编jai*_*d12的帖子

什么是Spring4.0.3中AuthenticationException.getAuthentication()的替代品

我在我的项目中使用Spring 3,现在升级到Spring 4.0.3.RELEASE.现在在使用时AuthenticationException.getAuthentication(),它表示已弃用,但无法找到备选方案.这是代码:

public ModelAndView init(HttpServletRequest request, HttpServletResponse response) {
    AuthenticationException exception = (AuthenticationException) request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);

    Authentication loginAuthentication = exception.getAuthentication();

    // Set the user name for the change password screen
    return new ModelAndView("common/changePassword", "userName", loginAuthentication.getPrincipal());   
}
Run Code Online (Sandbox Code Playgroud)

该方法setAuthentication(authentication)也已弃用.这两种方法有其他选择吗?

java spring spring-security

8
推荐指数
1
解决办法
803
查看次数

标签 统计

java ×1

spring ×1

spring-security ×1