checkboxがバックグラウンドに複数のname同じvalueを送信する場合の2つの属性駆動受信方式
1396 ワード
(checkbox) name ,value ,
: , , ... value hobbies ,
:
:
Action :
1:
public class Demo extends ActionSupport{
// name checkbox( ) Action
private String ids;
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
public String execute() throws Exception {
System.out.println(ids); // :1, 2, 3, 4, 5
return SUCCESS;
}
: , value
, ,
String[] id = ids.split(", ");
2:
public class Demo2 extends ActionSupport{
// name checkbox( ) Action
private String[] ids;
public String[] getIds() {
return ids;
}
public void setIds(String[] ids) {
this.ids = ids;
}
public String execute() throws Exception {
for (String id : ids) {
System.out.print(id); // , 12345
}
return SUCCESS;
}