Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只要请求没关闭,当前线程的任何地方都能注入HttpServletRequest #6

Open
coderstory opened this issue Dec 31, 2019 · 0 comments

Comments

@coderstory
Copy link

@component
public class myAuthenticationProvider extends DaoAuthenticationProvider {
private HttpServletRequest request;

public myAuthenticationProvider(UserDetailsService userDetailsService, HttpServletRequest request, PasswordEncoder passwordEncoder) {
    this.request = request;
    // 注意是使用set
    this.setUserDetailsService(userDetailsService);
    this.setPasswordEncoder(passwordEncoder);
}

@Override
protected void additionalAuthenticationChecks(UserDetails userDetails,
                                              UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
    super.additionalAuthenticationChecks(userDetails, authentication);
}

}
4.2章节里为什么搞得这么麻烦?
P53页看的时候 就感觉不太对
不知道这些代码的内容是怎么来的。。。很多代码都是new对象而不是注入

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant