Results 1 to 2 of 2

Thread: Controller Dispatch based on domain of URL on request

  1. #1
    Join Date
    Nov 2010
    Posts
    1

    Default 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

  2. #2
    Join Date
    Jan 2006
    Location
    Perú
    Posts
    4

    Default

    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
    Abner Ballardo Urco
    MoDuLe LoSt - http://www.modlost.net

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
  •