我正在尝试Reverse routing示例代码
这是我的路线
GET /hello/:name controllers.Application.hello(name)
GET /bob controllers.Application.helloBob
和我的代码
def helloBob = Action {
Redirect(routes.Application.hello("Bob"))
}
def hello(name: String) = Action {
Ok("Hello " + name + "!")
}
我可以得到你好的回复
$ curl -v localhost:9001/hello/play
Hello play!
但是,无法获得" Bob"重定向后的响应?
$ curl -v localhost:9001/bob
* Trying ::1...
* Connected to localhost (::1) port 9001 (#0)
> GET /bob HTTP/1.1
> Host: localhost:9001
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 303 See Other
< Location: /hello/Bob
< Date: Fri, 18 Sep 2015 03:19:04 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
答案 0 :(得分:2)
URI的路径组件区分大小写。检查一下。
尝试
curl -v localhost:9001/hello/Bob
<强>更新强>
您的代码是正确的(在我的项目中验证)并显示正确的日志 - 它打印303代码。我想,你只需要说curl跟随重定向,就像这样
curl -L localhost:9000/bob