Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to differentiate domains using Spring RequestMapping

Tags:

java

url

spring

dns

I'm trying to use different methodes depending on from which domain the request is send.

e.g.

@RequestMapping(value = "/index.html", domain = "google.de", method = RequestMethod.GET)
public ModelAndView handleDeRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
}

@RequestMapping(value = "/index.html", domain = "google.com", method = RequestMethod.GET)
public ModelAndView handleComRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
}

The two domains are routing to one, the same, server and webapp, but I'd like to return a different modelAndView in the controllerclass depending from which URL the reqeust is comming.

Any ideas?

cheers.

like image 559
Nils Avatar asked Oct 10 '22 18:10

Nils


1 Answers

Can you not have a single handleRequest method where you simply check HTTP referrer header and act correspondingly - fork into different methods, etc.?

like image 71
mindas Avatar answered Oct 17 '22 01:10

mindas