0

I need to get the web server root / host URL part (and possible port). Example: https://www.example.net

I don't care about the context path or the complete URI. I know there has to be some static context set in Spring somewhere that I can access or inject this information into my service class but I cannot find it, and all I see are articles about how to set the application context.

Edit: Also, I do not want to have to pass it from the HttpRequest object.

Is there a static method from some Spring context that will return me this information?

Encryption
  • 1,809
  • 9
  • 37
  • 52
  • Why not use the HttpRequest object? Also, have you seen htis: https://stackoverflow.com/questions/29929896/how-to-get-local-server-host-and-port-in-spring-boot – aardbol Mar 29 '19 at 19:39
  • @EarthMind because surely there is a way that spring hooks into the web server to retrieve basic information about where it lives? Passing the string from the controller all the way through to my service seems a bit like excessive if there is a better option. – Encryption Mar 29 '19 at 20:33

0 Answers0