action中  FreightPolicyQueryAction extends ActionSupport implements
ServletRequestAware, ModelDriven<FreightPolicyQueryModel>
.....
                  String[] insurance = new String[2];
insurance[0] = "1";
insurance[1] = "2";
LOG.info(insurance.length);
getModel().setInsurance(insurance);//给驱动模型设置值
if (getModel().getInsurance() != null) {
LOG.info(getModel().getInsurance().length);
for (int i = 0; i < getModel().getInsurance().length; i++) {
LOG.info(getModel().getInsurance()[i]);
}
}
return "fpQueryInit";<td width="75%">
<s:checkboxlist name="insurance" theme="simple"
labelposition="right" list="#{'1':'国内','2':'进口'}"
listKey="key" listValue="value"></s:checkboxlist>
</td>
想实现的就是从action中给jsp设置checkboxlist的值...网上找了一下,好象设置同名的数组就可以了.我的insurance是在modeldriven中写的. 也试过直接在ACTION中写数组赋值但是还是赋不上去.

解决方案 »

  1.   

    action中有insurance数组还是一样给你填到modelDriven里去了.!
    你现在什么问题? 值没有给model填进去?
      

  2.   

    值已经写入modelDriven了,可是页面上对应的checkboxlist没有被选中
      

  3.   

    从你的代码里我没看出来要做数据回显!
    fpQueryInit你这个视图里面跳转到哪个jsp
      

  4.   


    <td width="75%">
                                                <s:checkboxlist name="insurance" theme="simple"
                                                    labelposition="right" list="#{'1':'国内','2':'进口'}"
                                                    listKey="key" listValue="value"></s:checkboxlist>
    </td>fpQueryInit跳转的就是上面的这个JSP.我的想法是modelDriven和struts1的actionform是差不多意思.