Struts 1.1 中 html:checkbox 标签的使用

Posted on 2008-02-28 18:03  肥蛋  阅读(2532)  评论(1)    收藏  举报
在 JSP 中:
<html:checkbox property="checkbox" value="on" />

在对应的 ActionForm 中:
public String getCheckbox() {
    
return checkbox;
}

public void setCheckbox(String s) {
    
if (s == null) {
        checkbox 
= "";
    } 
else {
        checkbox 
= s;
    }
}

要让该 checkbox 选中,则调用:
xxx.setCheckbox("on");

要判断该 checkbox 是否被选中,则调用:
if (xxx.getCheckbox().equals("")) {
    
// checkbox 没有被选中
else {
    
// checkbox 已被选中
}

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3