【问题标题】:How to differentiate domains using Spring RequestMapping如何使用 Spring RequestMapping 区分域
【发布时间】:2011-06-15 08:43:34
【问题描述】:

我正在尝试使用不同的方法,具体取决于发送请求的域。

例如

@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 {
}

这两个域正在路由到同一个服务器和 webapp,但我想在控制器类中返回不同的 modelAndView,具体取决于请求来自哪个 URL。

有什么想法吗?

干杯。

【问题讨论】:

    标签: java spring url dns


    【解决方案1】:

    你不能有一个单一的handleRequest 方法来简单地检查 HTTP 引用标头并采取相应的行动 - 分叉成不同的方法等吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      • 1970-01-01
      相关资源
      最近更新 更多