我在我的项目中使用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)也已弃用.这两种方法有其他选择吗?