gpt4 book ai didi

PlayFramework 2.0.2 路由中的多个参数

转载 作者:行者123 更新时间:2023-12-04 05:35:15 26 4
gpt4 key购买 nike

如果我添加一个参数,我似乎无法让多个参数工作,只要我添加第二个参数,一切都很好,我总是得到一个

No data received
Unable to load the webpage because the server sent no data.
Here are some suggestions:
Reload this webpage later.
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

其他任何人都可以确认您可以使用 play 2.0.2 向请求添加第二个参数吗?
(使用Java)

我的网址就这么简单
http://localhost:9000/account/foruser?username=somethig&create=0

和路线
GET     /account/foruser
controllers.user.UserController.foruser(username:String, create:Boolean )

最佳答案

你应该多注意路线 docs and samples

通常,如果您使用带有 &name=value 的命名参数您不需要在路由文件中指定它们。而是使用 Java 中的 DynamicForm 来访问它们。

路由文件用于匹配unnamed与 Controller 的 Action 和参数的链接部分。所以你的链接应该是这样的:

http://localhost:9000/account/foruser/something/0

和路线(当然这需要放在路线文件中的一行:
GET     /account/foruser/:username/:create
controllers.user.UserController.foruser(username: String, create: Integer )

请注意,有一些关于在路由中使用 bool 类型的错误报告,因此使用一些数字类型更安全。

关于PlayFramework 2.0.2 路由中的多个参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11911263/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com