在struts框架下使用post提交数据并回带处理结果

js部分代码

//删除单个
  function deleteStu(id){
   $.messager.confirm('提示','确定要删除该行记录吗?',function(b){
    if(b){
     //提交删除行的id
     $.post('delStudent.action',{delId:id},function(result){
      $('#stutab').datagrid('reload');
      //使用消息框显示消息
      showMessage(result.resultMsg);
     },'json');
    }
   });
  }

后台处理部分代码

//删除信息
 public String delStudent(){
  String result="";
  try{
    this.resultMsg=ss.delStudents(idList);
   result=SUCCESS;
   request.getSession().setAttribute("find", "find");
  }catch(SQLException e){
   this.setResultMsg("数据库查询异常");
   result="errorSQL";
  }catch(Exception e){
   result="error";
   this.setResultMsg("逻辑有问题");
  }finally{
   return result;
  }
 }

struts配置部分代码
  <package name="study" extends="json-default"> 
        <action name="*" class="cn.eduask.action.StudyAction" method="{1}">
            <result name="success" type="json">
             <param name="resultMsg"></param>
            </result>
        </action>
    </package>

posted @ 2012-04-28 09:23  sjhnanwang  阅读(210)  评论(0编辑  收藏  举报