Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring - Getting domain name in use

Tags:

url

spring-mvc

I have a Spring application running that uses SpringMVC and EclipseLink.

This application works well with multiple top level domains at the same point, for example you can access:

http://www.foo.com/user/list
http://www.anotherdomain.com/user/list
http://www.company.com/user/list

But now I need to load a customized design for each domain, so I need to identify what is the domain that's accessing.

I'll need to implement a class that would set views path, etc.

Anyone knows a good solution for this?

like image 355
Felipe Ferreira do Amaral Avatar asked Mar 11 '15 15:03

Felipe Ferreira do Amaral


1 Answers

Get it from Header "Host". In Spring

  • you can try @RequestHeader String host in controller method as parameter.

OR

  • get it from HttpServletRequest.getHeader("host")
like image 89
Braj Avatar answered Oct 20 '22 12:10

Braj