如何从 displaytag 中的 struts2 复选框获取复选框值到操作类

2023-10-15Java开发问题
2

本文介绍了如何从 displaytag 中的 struts2 复选框获取复选框值到操作类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在开发 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[] 添加到与您的复选框命名相同的操作中并通过访问器(getter/setter)公开它,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 复选框获取复选框值到操作类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
11

如何在 Java 中从 DB 加载资源包消息?
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13