paramquery不会加载servlet URL JSON字符串?

时间:2017-01-02 11:36:49

标签: java json function servlets

下面是index.xhtml我无法获取加载和显示数据的url。 servlet运行正常,JSON字符串正确返回为

{"data":[{"LASTNAME":"Leonard","PERSON_ID":"0","FIRSTNAME":"Erick","FULLNAME":"Erick Leonard"}]}

我认为挑战是使用URL或var dataModel = area

中的getData
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css"/>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"/>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"/>
    <h:outputStylesheet name="css/pqgrid.min.css"/>
    <h:outputScript name="js/pqgrid.min.js"/>           
    <h:outputScript name="js/jquery.ui.touch-punch.js"/>

<script>
$(function()
    {
    var dataModel =
        {   location: "remote",
            dataType: "JSON",
            method: "GET",
            url: "queryreturn",
            getData: function (dataJSON)
            {  return { data: dataJSON.data };  }           

        }    
    var obj = {};
    obj.dataModel = dataModel;

    obj.width = 700;
    obj.height = 400;   
    obj.colModel = [
        { title: "Person ID", width:100, dataType: "int", dataIndx: "person_id"},
        { title: "Full Name", width:200, dataType: "string", dataIndx: "fullname"},
        { title: "First Name", width:150, dataType: "string", dataIndx: "firstname"},
        { title: "Last Name", width:150,  dataType: "string", dataIndx: "lastname"}];

    $("div#grid_array").pqGrid( obj );
    });
</script>

</h:head>
<h:body>
<div id="grid_array"></div> 
</h:body>
</html>

1 个答案:

答案 0 :(得分:0)

首先,javascript区分大小写,JSON字符串返回CAPS中的列名。

附加错误是一个未找到的JSTL jar文件,一旦我将程序更改为Maven并添加了依赖项,它就在本地运行。