`
pengfeicao521
  • 浏览: 140465 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

ajax jsonObject struts2

阅读更多
1 前台通过jquery 与struts2 action 交互

          $.ajax({
           url: "<%=rootPath%>/index!comInitGroupEdit.action?groupId="+groupId,  
           type:"post",           
           dataType:"json",  
           success: function(json){
                var allGroupArray = json.allGroupArray;
                var groupByIdArray = json.groupByIdArray;            
             $.each(allGroupArray, function(i){
                //  window.alert("  groupByIdArray[0].PARID: "+groupByIdArray[0].PARID+ "  allGroupArray[i].ID: "+allGroupArray[i].ID);
            if(groupByIdArray[0].PARID==allGroupArray[i].ID){
               tempHTML1= " <option  selected   value="+ allGroupArray[i].ID  + ">"+allGroupArray[i].NAME ;
              }else{
                   tempHTML1= " <option   value="+ allGroupArray[i].ID  + ">"+allGroupArray[i].NAME ;
              }
  });                   
         $("#groupName").val(groupByIdArray[0].NAME);
         $("#oldGroupName").val(groupByIdArray[0].NAME);
           }
      });  

2 后天通过struts2 action 取数据

public  String comInitGroupEdit(){
String queryAllGroup =" SELECT tg.group_id ID,tg.group_name NAME   FROM tb_iap_tgt_group  tg ORDER BY tg.group_id ASC  ";
String queryGroupById ="  SELECT tg.group_id ID ,tg.group_id_parent parId ,tg.group_name NAME FROM tb_iap_tgt_group  tg WHERE tg.group_id="+groupId;
Map<String,Object> map = new HashMap<String, Object>();

map.put("querySql",queryAllGroup);
     List<Map<String,Object>> results = indexService.getCommonQuery("getCommonQuery",map);
JSONArray allGroupArray=JSONArray.fromObject(results);
jsonObject.put("allGroupArray", allGroupArray);

map.put("querySql",queryGroupById);
     results = indexService.getCommonQuery("getCommonQuery",map);
JSONArray groupByIdArray=JSONArray.fromObject(results);
jsonObject.put("groupByIdArray", groupByIdArray);


return "jsonObject";
}
分享到:
评论

相关推荐

    ajax json实现异步联动_JSONObject

    依赖包 博文链接:https://yanglei008.iteye.com/blog/215878

    JSONObject相关依赖架包

    JSONObject相关依赖架包,包含1、com.alibaba.fastjson.JSONArray依赖jar 2、net.sf.json.JSONObject依赖jar

    JsonObject(免分)

    JsonObject

    JsonObject转换Date日期

    JsonObject转换Date日期的时候出现问题解决date封装成json数据出现的问题

    JsonObject

    引用using Xfrog.Net; 用法如: JsonObject newObj = new JsonObject("json字符串"); String errorCode = newObj["error_code"].Value;//获取其中的属性值。

    JSONObject依赖的Jar包.rar

    在web项目中经常会用到json数据(如:struts2处理请求返回json数据给jsp解析),因此,JSONObject对象是必备的,这时就需要引入相关的jar包了。

    org.json.JSONObject引用依赖包

    org.json.JSONObject引用依赖包 org.json.JSONObject引用依赖包 org.json.JSONObject引用依赖包 org.json.JSONObject引用依赖包

    JAVA JSONObject Jar包

    JAVA JSONObject Jar包

    jsonObject

    jsonObject、jsonArray

    JSONObject

    文件名称:JSONObject.rar(可用其他解压器解压),内含文件若干(6个)如下 commons-beanutils-1.9.1.jar commons-collections-3.2.1.jar commons-lang-2.6.jar commons-logging-1.1.1.jar ezmorph-1.0.6.jar json-lib-...

    JSONObject所需的6个依赖jar包

    包含JSONObject所需依赖的6个jar包 以及JSONObjectAPI文档 和 JSONObject源码 其中文档直接解压压缩包在文件夹中的index.html打开,源码在你的ide编辑器中引入就可以查看JSONObject实现源码

    JSONObject对象依赖的jar包

    Java开发当中经常设计到Json格式的数据使用,这就用到JSONObject类,依赖这些jar架包即可。

    jsonobject.zip

    如果想要在Java中使用JSONObject,而且只想通过导入jar包的方式下,那么仅仅导入Json的jar包还是不够的。JSONObject完整所需jar包,注意版本问题。

    使用JSONObject的所有包

    使用JSONObject的所有包

    JSONObject用法

    JSONObject用法 ,分享给大家

    JsonObject jar包

    JsonObject jar包

Global site tag (gtag.js) - Google Analytics