我们已在ORDS和Weblogic应用服务器的应用服务器上安装了Oracle APEX。我们正在尝试使用它来创建简单的ReST API,以便从我们的数据库(11gR2)中获取数据。我开发了一个HTML页面,使用jqgrid
将json
数据从ReST API转换为Tabular网格。 GET
jqgrid
对URI的404 Resource not found
请求遇到jqgrid
错误。
$("#jqGrid").jqGrid({
url: 'http://nsrmss01:9002/ords/oracle_retail_rest/comm/js',
mtype: 'GET',
datatype: 'json'
styleUI : 'Bootstrap',
colModel: [
{ label: 'Database', name: 'DBNAME', width: 100,editable: true },
{ label: 'SID', name: 'DBSID', width: 100,editable: true },
{ label: 'Port', name: 'DBPORT', width: 100,editable: true },
{ label: 'Last Refreshed', name: 'LASTREFRESHED', width: 150,editable: true ,
edittype : 'text',
editoptions: {
// dataInit is the client-side event that fires upon initializing the toolbar search field for a column
// use it to place a third party control to customize the toolbar
dataInit: function (element) {
$(element).datepicker({
autoclose: true,
format: 'dd-M-yyyy',
orientation : 'bottom'
});
}
}
},
{ label: 'Server Status', name: 'STATUS', width: 150,editable: true ,
edittype: "select",
editoptions: {
value:"AVAILABLE:Available;UNREACH:Unreachable;DOWN:Down"}
}
],
viewrecords: true,
height: 250,
loadonce: true,
rowNum: 20,
pager: "#jqGridPager"
});
代码如下所示 -
jqgrid
该网页有一个简单的json
表,该表应加载dbdata
内容,如下所示(json
数组上的{
"dbdata": [
{
"dbname": "servdbp01",
"dbsid": "PROD",
"dbport": 1621,
"status": "AVAILABLE"
},
{
"dbname": "servdbd06",
"dbsid": "DEV01",
"dbport": 1621,
"lastrefreshed": "2015-01-01T08:00:00Z",
"status": "AVAILABLE"
},
{
"dbname": "servdbd06",
"dbsid": "SUP01",
"dbport": 1621,
"lastrefreshed": "2015-02-15T08:00:00Z",
"status": "AVAILABLE"
}
]
}
行为3行) -
jsonReader : {root: "dbdata"}
我还在jqgrid
中尝试content-type
作为选项。
浏览器调试显示了这个 -
我注意到该服务发送的响应标头中的text/html
为content-type
,如下所示 -
application/json
应datatype:'jsonstring'
吗?这是问题吗?如果是这样,我如何更改/配置ORDS以设置内容类型?我正在使用APEX UI创建ReST API,并测试了API以通过APEX测试和SoapUI进行工作。我已经看过这里以及其他关于这个问题的地方,但找不到任何相关内容,所以我们将非常感谢任何帮助。
注意:如果我使用$.getJSON()
,则错误消失,但我不知道如何将响应转换回字符串。如果我使用JSON
获取$.getJSON('http://nsrmss01:9002/ords/oracle_retail_rest/comm/js', function(data) {
console.log(data);
});
数据,我会得到正确的回复(请参阅下面的屏幕截图和代码)。但我只是不确定如何在JQGrid中使用它。
import pandas
import glob
json_files = glob.glob('*.json')
def merge_files(json_files):
dfs = list()
for json_file in json_files:
df = pandas.read_json(json_file)
dfs.append(df)
df = pandas.concat(dfs)
return df
df = merge_files(json_files)
答案 0 :(得分:2)
错误404错误的原因可能是参数,它们将被发送到服务器。您应该添加jqGrid选项prmNames
以禁止发送_search
,nd
和其他:
prmNames: { nd: null, search: null, sort: null, order: null, rows: null, page: null }
然后,您应该修复name
中使用的colModel
属性的值。 JavaScript区分大小写,您必须使用name: 'dbname'
代替name: 'DBNAME'
。
最后,我建议您使用free jqGrid而不是目前使用的商业Guriddo jqGrid JS。免费jqGrid可以在MIT或GPL v2许可下完全免费使用。您只需将styleUI : 'Bootstrap'
参数更改为guiStyle: "bootstrap"
即可。有关详细信息,请参阅the article。在代码生效后,可以进行其他优化。