程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> spring-dwr+easyui加載不出數據

spring-dwr+easyui加載不出數據

編輯:編程綜合問答
dwr+easyui加載不出數據

系統的框架為dwr+easyui+spring,easyui通過dwr的方式向發送請求至spring的控制層,並且,可以正常訪問,但是,easyui始終不能顯示返回的數據,代碼如下:

[easyui]層:
$(function () {
$("#dg").datagrid({
title : '訂單列表',
iconCls : 'icon-ok',//圖標

toolbar : "#tb",
view:'scrollview',
width:'auto',
height:'auto',
fit:true,//自動補全

loadMsg:'正在加載數據,請稍候...',
singleSelect: true,//只能選擇單行

fitColumns : true,//允許表格自動縮放,以適應父容器

autoRowHeight: false,
rownumbers:true,//顯示序號
collapsible : true,//顯示可折疊按鈕
columns: [[{
field: "orderId",
title: "訂單號",
align: 'left',
width: 200
}, {
field: "orderTime",
title: "下單時間",
align: 'left',
width: 200
}]],
url: findOrder()//調用獨立方法通過dwr的方式訪問後台
})//datagrid

[dwr]層:
function findOrder(){
var param={};

refundAction.findOrder(JSON.stringify(param),{

    callback:function(data){

        var jsonStr = data.param.jsonStr;
        console.log(jsonStr);
        return jsonStr;
    },
    exceptionHandler: function(message,exc) {
        orgmain.errorHander(message, exc);
    }
});

};

[Controller]層
@RemoteMethod
public Result findOrder(String params,HttpSession session) throws SystemException
{
Result result = new Result();
JSONObject json=JSONObject.fromObject(params);
String jsonStr = refundService.findOrder(json);
Map map=new HashMap();
map.put("jsonStr", JSONObject.fromObject(jsonStr));
result.setCode(ResultCode.R_SUCCESS);
result.setMsg("查詢成功");
result.setParam(map);
return result;
}

通過測試,dwr是獲取到值的,但是不知道easyui有沒有獲取到值,總是加載不出數據,請高人指點。

最佳回答:


換一種寫法試試,代碼如下:

 if(data.code == "R-0000"){
            var json = data.param.json;
            console.log(json);
            $("#mytable").datagrid('loadData', json);
        }else{
            $.messager.alert('溫馨提醒',data.msg);
        }
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved