问题描述
我正在使用 struts2 应用程序,我正在使用 displaytag 进行分页支持。
I am working on struts2 application in which i am using displaytag for pagination support.
现在我我想要一个表格中每一行的复选框。
Now i want a check box for each row in the table for that i am doing this.
<display:table name="countryList" export="true" class="table" id="countryList" pagesize="${selectedPageSize}" decorator="org.displaytag.decorator.TotalTableDecorator" >
<display:column property="id" title="ID" paramId="id" />
<display:column property="name" title="Name" sortable="true"/>
<display:column title="Delete All">
<s:checkbox id="check" name="check" fieldValue="%{#attr.countryList.id}" theme="simple"/>
</display:column>
</display:table>
<s:submit action="deleteall" value="DeleteSelected" />
直到这里工作正常。现在我想删除通过复选框检查的所有国家。
till here its work fine. now i want to delete all the countries that are checked through the check box.
我想要检查的国家/地区的ID。因为我必须采取数组中的值。
for that i want the ids of the countries that are checked .for that i have to take the values in an array.
问题是如何从jsp发送值然后在动作类中获取它
The problem is how can i send the values from jsp and then get it at the action class
推荐答案
如果你将一个String []添加到与你的复选框相同的动作中,并通过访问器(getters / setters)公开它,struts 2应自动填充它。
If you add a String[] to your action named the same as your checkbox(s) and expose it via accessors (getters/setters) struts 2 should auto populate it.
这篇关于如何从displaytag中的struts2复选框获取复选框值到action类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!