Supposing I have two subdomains:
Products:
products.example.com
Users:
users.example.com
How do I set up a single Spring MVC app to handle each of these domains differently (in my case I want to use a different database depending on which subdomain the user arrives from)?
If the same applications is to be used with the multiple subdomains, then you can make an interceptor (implement HandlerInterceptor
) that is invoked for every request and store the subdomain in a ThreadLocal
. Then, based on that value, you can differentiate your actions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With