问题:
http://localhost:8080/site/google.com
参见以下 Spring REST 示例,如果提交了诸如此类的请求,则 Spring 返回“<strong>google”。看起来像春天对待“。” 作为文件扩展名,并提取参数值的一半。
Spring 必须返回“<strong>google.com”。怎么办?
站点控制器.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";
}
}