解决方案 »

  1.   

    你前台有selectedIds?
    你后台有selectedIds  接受吗。?
      

  2.   

    后台有的,我想问的是这个id是和数据库中表的id还是表格的id?如果是数据库表中的id应该在前台怎么写?
      

  3.   

    没看懂,你不是不是说没有。 
    $.post("deleteUsers.action?selectedIds="+ids  这个 selectedIds 是传到后台的。
    现在无论什么情况你 ids   必须有数据, 其次后台也能 取到 selectedIds 这个参数。
      

  4.   


    嗯嗯,我想问的问题就是这个ids是怎么来的?这个例子可以完成删除操作,数据库也是可以删除的,我就是看不懂,所以来问问,
    我把代码贴上来,帮我看下。
    前台:
    <script type="text/javascript">
    $(document).ready(function() {
    initCommonJS();
    $("#gridTable").datagrid({
    url:'fetchPersonList.action?t=' + new Date(),
    width:750,
    sortName: 'name',
    sortOrder: 'desc',
    pagination:true,
    rownumbers:true,
    pageList:[15,30,50,100],
    columns:[[
        {field:'id',title:'id',width:30,hidden:true},
        {field:'ck',checkbox:true,width:30},
        {field:'name',title:'姓名',width:80,sortable:true},
        {field:'age',title:'年龄',width:60,align:'center',sortable:true}
    ]],
    toolbar:[{
    id:'btnadd',
    text:'增加',
    iconCls:'icon-add',
    handler:function(){
    checkOpenUrl("#gridTable","useredit.html",550,420,"增加","用户");
    }
    },{
    id:'btnremove',
    text:'删除',
    iconCls:'icon-remove',
    handler:function(){
    checkSelectSomeDoFunc("#gridTable","删除","用户",
    function(ids){
      $.post("deletePerson.action?selectedIds="+ids+"&t="+new Date(),{},function(result){
      if (result=="success"){
       $("#gridTable").datagrid("reload");
      }else{
      alert(result);
      }
      });
    },
    true
    );
    }
    },{
    id:'btnedit',
    text:'修改',
    iconCls:'icon-edit',
    handler:function(){
    checkSelectOneOpenUrl("#gridTable","useredit.html",550,420,"修改","用户");
    }
    }]
    });
          });
    </script>
    </head>
    <body>
    <table id="gridTable"></table>
    </body>
    </html>后台:
    private IPersonService personService;
    private String selectedIds;
    private int total;
    private List<Person> rows=new ArrayList<Person>();
    private int person_id;
    private String name;
    private int age;
    public void deletePersons() throws Exception{
    System.out.println("开始删除了"+selectedIds);
    HttpServletResponse response = ServletActionContext.getResponse();
    response.setContentType("text/html;charset=UTF-8");
    try{
    String[] ids = this.selectedIds.split(",");
    for (int i=0;i<ids.length;i++){
    this.personService.delete(Integer.valueOf(ids[i]));
    }
    response.getWriter().write("success");
    }catch(Exception ex){
    System.out.println(ex);
    response.getWriter().write("删除用户出错!");
    }
    }
      

  5.   

    虽然不知道他是怎么获取值的,但是把数据库中的表的字段改成ID就好了!!还是希望有人知道的告诉下小弟,谢谢。。告诉下获取值的原理!在action里面数出来看下,它获得的是数据库表中的id,并不是前台表格的id!
      

  6.   

    应该是框架在你选择了多个用户的时候自己构造出来的。你看ckbox列是否添加了事件?