-
Nov 22nd, 2010, 10:36 AM
#1
Controller Dispatch based on domain of URL on request
Is it possible to get the DispatcherServlet to dispatch to different Controllers based on the domain of the URL on the request?
i.e. My site can be accessed via two domains...
http://mysite.com/
http://xyz.mysite.com/
...and ideally I'd like to have two separate controllers for handling each of the above despite the request path being the same (i.e. / in the above example).
A quick example:
@Controller
public class HomeController {
...
@RequestMapping("/")
public String showHomePage() {}
}
@Controller
public class XyzHomeController {
...
@RequestMapping("/")
public String showHomePage() {}
}
NB: I'm trying to avoid having to use rewrite rules
Thanks
Dan
-
Nov 22nd, 2010, 10:37 PM
#2
There's not out-of-the-box handler mapping that do what you expect but for sure you can write your one implementation of org.springframework.web.servlet.HandlerMapping that uses domain names as another way to select a controller/method
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules