gpt4 book ai didi

java - Play 1.2.4 :Retrieving hidden variable value in Controller

转载 作者:行者123 更新时间:2023-12-01 14:18:28 25 4
gpt4 key购买 nike

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

我使用以下方法在 .html 文件中设置隐藏变量:

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

为了检索 Controller 中隐藏变量的值,我使用了以下内容:

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

但不幸的是,字符串 str 的值是 null,这意味着它不起作用。

请告诉我如何检索 Controller 中的隐藏变量值。

编辑

<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>

关于java - Play 1.2.4 :Retrieving hidden variable value in Controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17885771/

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