在Spring中,当用户登录时,我需要在自定义MyUserDetailsService中做额外的验证,并且我需要用户登录的域名。有什么想法吗?
下面是我在How do I get the Session Object in Spring?上得出的结论
发布于 2014-06-19 18:49:16
你可以像下面的代码一样将HttpServletRequest注入到你的MyUserDetailsService中,我相信getRemoteHost()就是你要找的?
@RestController
public class WebOneController {
@Autowired
private HttpServletRequest request;
@RequestMapping("/")
public String hello() {
return "host " + request.getRemoteHost();
}
}https://stackoverflow.com/questions/24298916
复制相似问题