答案 0 :(得分:0)
你可以将HttpServletRequest注入(@Autowired)你的MyUserDetailsService,类似于下面的代码,我相信getRemoteHost()就是你想要的吗?
@RestController
public class WebOneController {
@Autowired
private HttpServletRequest request;
@RequestMapping("/")
public String hello() {
return "host " + request.getRemoteHost();
}
}