【发布时间】:2013-02-06 17:32:38
【问题描述】:
问题:
参见下面的 Spring REST 示例,如果提交了 http://localhost:8080/site/google.com 之类的请求,则 Spring 返回“google”。看起来像春天对待“。”作为文件扩展名,并提取一半的参数值。
Spring 必须返回“google.com”。怎么办?
SiteController.java
package com.example.web.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/site")
public class SiteController {
@RequestMapping(value = "/{domain}", method = RequestMethod.GET)
public String printWelcome(@PathVariable("domain") String domain,
ModelMap model) {
model.addAttribute("domain", domain);
return "domain";
}
}
【问题讨论】:
标签: spring spring-mvc