【发布时间】:2014-04-24 17:13:46
【问题描述】:
如果 testId 为 1211.ml:FA890987422,我如何对以下方法进行 URL 调用。由于 testId 中有一个 ':',我尝试使用 URLEncoding (%3A for :) 发出请求,如下所示
http://localhost:8080/test/1211.ml%3AFA890987422
当我使用上面的 URL 时,我得到 testId 作为 1211 而不是 1211.ml:FA890987422 即使是 '.'不需要 URL 编码。我究竟做错了什么?另外,如果我想跳过 URL 编码,还有其他方法可以将这个 testId 传递给这个方法吗?
@RequestMapping(value = "/test/{testId}",
method = RequestMethod.GET,
produces = "application/xml")
public @ResponseBody String testResource(
@PathVariable String testId){
System.out.println("Test Id: "+ testId)
// other codes follow
}
【问题讨论】: