播放1.2.4:检索控制器中隐藏的变量值



我的应用程序使用Play 1.2.4框架。

我正在使用以下命令设置.html文件中的隐藏变量:

<input type="hidden" name="test" value="test">

为了检索控制器中隐藏变量的值,我使用了这个:

String str = request.params.get("test");

但不幸的是,Stringstr的值是null,这意味着它不起作用。

请让我知道如何检索控制器中的隐藏变量值。

编辑

<center>            
    <table>         
        <tr style="height: 100px">
            <td><h1>
                    <b>Title</b>
                </h1></td>
        </tr>
        <tr>
            <td>#{a @Application.userList()} Click Me#{/a}</td>
            <input type="hidden" name="test" value="test">
        </tr>
    </table>        

您应该将<input>标记放在<form>标记后面。然后,使用您的<a>标签进行表单请求。代码如下所示:

<center>
<table>
    <tr style="height: 100px">
        <td><h1>
                <b>Title</b>
            </h1></td>
    </tr>
    <tr>
        <td>
            <form action="@{Application.userList()}" id="myform" method="get">
                <a onclick="document.getElementById('myform').submit();">Click Me</a>
                <input type="hidden" name="test" value="test">
            </form>
        </td>
    </tr>
</table>    

最新更新