Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Struts2:隐藏字段和锚标签<;s:a>;行动课中的价值观_Struts2 - Fatal编程技术网

Struts2:隐藏字段和锚标签<;s:a>;行动课中的价值观

Struts2:隐藏字段和锚标签<;s:a>;行动课中的价值观,struts2,Struts2,我正在开发struts2应用程序。在我的jsp页面中,我有2-3个锚定标记和2-3个隐藏字段,如 <s:a href="#">File 1</s:a> <s:a href="#">File 2</s:a> <s:a href="#">File 3</s:a> 文件1 文件2 文件3 及 现在,请让我知道,在我的动作类中,我如何获得所有隐藏字段和被单击的锚定标记的值 我试过跟随 <s:a href="#" act

我正在开发struts2应用程序。在我的jsp页面中,我有2-3个锚定标记和2-3个隐藏字段,如

<s:a href="#">File 1</s:a>
<s:a href="#">File 2</s:a>
<s:a href="#">File 3</s:a>
文件1
文件2
文件3


现在,请让我知道,在我的动作类中,我如何获得所有隐藏字段和被单击的锚定标记的值

我试过跟随

<s:a href="#" action=”someAction”>File 1</s:a>
文件1
它可以工作,但不能传递隐藏文件的值。 也

文件1
但没有收获


正在寻找您的回复。

正如Boris所说,您需要将隐藏字段放入表单中,然后提交该表单,或者您可以将其作为URL参数添加到链接中。最好的方法可能是使用带有POST的表单,这样隐藏字段就不会出现在浏览器的位置栏上

这里有一个例子

<s:form id="myform" name="myform" action="someAction" method="POST">
<s:hidden name=" hidden1" value="first value"/>
<s:hidden name=" hidden2" value="second value"/>
<s:hidden name=" hidden3" value="third value"/>

<a href="#" name="file1" onclick="document.forms['myform'].submit();">Submit with link</a>

<s:submit value="%{'Submit with button'}" />

</s:form>

由于这与struts2没有任何关系,下面是一个纯HTML示例:

<form id="myform" name="myform" action="someAction.action" method="POST">
<input type="hidden" name=" hidden1" value="first value"/>
<input type="hidden" name=" hidden2" value="second value"/>
<input type="hidden" name=" hidden3" value="third value"/>

<a href="#" name="file1" onclick="document.forms['myform'].submit();">Submit with a link</a>
<br/>
<input type="submit" value="Submit with a button"/>

</form>



也许这听起来很傻,但您是否已将这些隐藏字段包含在表单标记中?
<s:form id="myform" name="myform" action="someAction" method="POST">
<s:hidden name=" hidden1" value="first value"/>
<s:hidden name=" hidden2" value="second value"/>
<s:hidden name=" hidden3" value="third value"/>

<a href="#" name="file1" onclick="document.forms['myform'].submit();">Submit with link</a>

<s:submit value="%{'Submit with button'}" />

</s:form>
<form id="myform" name="myform" action="someAction.action" method="POST">
<input type="hidden" name=" hidden1" value="first value"/>
<input type="hidden" name=" hidden2" value="second value"/>
<input type="hidden" name=" hidden3" value="third value"/>

<a href="#" name="file1" onclick="document.forms['myform'].submit();">Submit with a link</a>
<br/>
<input type="submit" value="Submit with a button"/>

</form>