简体   繁体   English

如何使用Play框架将参数从HTML代码传递到Java API?

[英]How to pass arguments to a java api from html code using play framework?

I want to pass arguments from HTML view to Java API in play framework. 我想将参数从HTML视图传递到play框架中的Java API。 I've written the following code. 我编写了以下代码。 What changes should be done to successfully pass the arguments from Html view to API in java controller?. 为了成功将参数从Html视图传递到Java控制器中的API,应该进行哪些更改?

When i tried passing it as @w.username and @w.email or by keeping '@w.username' or @w.username i've got error. 当我尝试将其作为@ w.username和@ w.email传递或通过保留'@ w.username'或@ w.username传递时,我遇到了错误。

@import model.User 
@(users: List[User]) 
<html>
    <body>
        <h1>Users</h1>

        <table>
            <thead>
                    <th>User Name</th>
                    <th>Email</th>
                    <th>Status</th>
            </thead>
        <tbody>
            @for(w <- users) {
            <tr>
                <td>@w.username</td>
                <td>@w.email</td>
                <td>@w.status</td>
                <td>            
                    <form action="@routes.UserController.getUser(w.username,w.email)">
                        <input type = "submit" value="View Deatils">
                    </form>
                </td>
            </tr>
            }
        </tbody>
    </table>
</body>
</html>

它必须像您写的那样工作:

@routes.UserController.getUser(w.username,w.email)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将java代码中的二维字符串数组传递给play框架中的scala.html? - How to pass a 2 dimensional string array from java code to scala.html in play framework? 如何使用java脚本window.location将参数传递给play框架中的java方法? - How to pass arguments using java script window.location to a java method in play framework? 如何在play(2.3)框架内的Java控制器代码中从String变量构造Html对象 - How do I construct an Html object from a String variable in Java controller code within the play (2.3) framework 如何将原始html传递给Play框架视图? - How to pass raw html to Play framework view? 如何使用shell脚本将参数传递给java代码 - How to pass arguments to a java code using shell script play框架 - 如何在play框架中使用java代码发送post请求 - play framework- how to send post request using java code in play framework 将参数从Shell脚本传递到Java代码 - pass arguments from shell script to java code 如何将Java对象传递到Play的模板中? [播放框架2.0] - How to pass Java object into Play's template? [Play framework 2.0] Play框架-如何返回play.twirl.api.Html - Play Framework- How to return play.twirl.api.Html 如何在Play框架模板的html标记中包含一段Java代码? - How to include a piece of java code inside a html tag in play framework template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM