Java Play 2-函数作为scala中的参数
我在用scala编写可重用代码时遇到问题 如果我有Java Play 2-函数作为scala中的参数,java,templates,scala,playframework-2.0,Java,Templates,Scala,Playframework 2.0,我在用scala编写可重用代码时遇到问题 如果我有 @helper.form(action = routes.Guides.addComment(category,title)) { 有没有办法用变量替换它 伪码 @(func : Function) @helper.form(action = func) { 编辑: 哦。。。。现在有点明显了。函数本身应该返回一个字符串,所以我想我可以这样说 @(func :String) .. @(func: String) <form acti
@helper.form(action = routes.Guides.addComment(category,title)) {
有没有办法用变量替换它
伪码
@(func : Function)
@helper.form(action = func) {
编辑:
哦。。。。现在有点明显了。函数本身应该返回一个字符串,所以我想我可以这样说
@(func :String)
..
@(func: String)
<form action="@func" method="POST">
现在测试它发现了它
与
您可以获取url,然后将其用作参数
比如说
@guidesComment((routes.Guides.addComment(ug.category,ug.title)).url)
指南提示看起来像这样
@(func :String)
..
@(func: String)
<form action="@func" method="POST">
然后像这样使用它
@(func :String)
..
@(func: String)
<form action="@func" method="POST">
找到了答案
与
您可以获取url,然后将其用作参数
比如说
@guidesComment((routes.Guides.addComment(ug.category,ug.title)).url)
指南提示看起来像这样
@(func :String)
..
@(func: String)
<form action="@func" method="POST">
然后像这样使用它
@(func :String)
..
@(func: String)
<form action="@func" method="POST">
我可以推荐一个替代方案吗?直接使用
@(route: Call)
@helper.form(action = route) {
...
}
在Scala中,您甚至可以只通过一部分路由,并从控制器填充其余路由(在使用分页时非常有用)。我可以推荐一种替代方法吗?直接使用
@(route: Call)
@helper.form(action = route) {
...
}
在Scala中,您甚至可以只传递路由的一部分,并从控制器填充其余部分(在使用分页时非常有用).你能解释一下如何使用它进行分页吗?你能单独问一个问题吗?你能解释一下如何使用它进行分页吗?你能单独问一个问题吗?