【发布时间】:2013-02-13 00:35:22
【问题描述】:
我在 Play 的路由中定义了这个简单的路由:
POST /test/post/$id<[0-9]+> controllers.Test.post(id: Long)
这是Test.post方法的代码:
public static Result post(long id)
{
return ok("working");
}
同一控制器中的另一条路由POST /test controllers.Test.index() 工作正常。但是,每当我访问http://localhost:9000/test/post/3 时,我会立即在 Firefox 中收到“连接重置”错误,而在 google chrome 中我会收到“空响应”错误。所有其他路线都正常工作。
我做错了什么?
【问题讨论】:
-
只是为了排除您错过明显情况的极不可能的情况:“每当我访问
http://localhost:9000/test/post/3”时,您的意思是通过POST请求,而不是通过在浏览器中输入地址? (因为您的路线看起来不错...无论如何,如果您确实通过GET访问它,您应该会收到一条找不到路线的错误消息...) -
只是一个小测试:在您的操作中使用
Long而不是long。 -
@nico_ekito 很好,就是这样。如果您愿意,请发布答案,我会接受。
标签: java playframework playframework-2.0