【问题标题】:unable to create jtable in jsp无法在jsp中创建jtable
【发布时间】:2013-05-08 06:12:30
【问题描述】:

嗨,我想在 jsp 中创建一个 jtable,经过大量谷歌搜索后,我找到了这个网站,因为这个网站说我会有一个默认表,但是当我运行它时,我得到一个空白页。请帮助我 http://jtable.org/GettingStarted#ListAction

   <html>
<head>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<!-- Include one of jTable styles. -->
<link href="/jtable/themes/metro/blue/jtable.min.css" rel="stylesheet" type="text/css" />

<!-- Include jTable script file. -->
<script src="/jtable/jquery.jtable.min.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $('#PersonTableContainer').jtable({
            title: 'Table of people',
            actions: {
                listAction: '/GettingStarted/PersonList',
                createAction: '/GettingStarted/CreatePerson',
                updateAction: '/GettingStarted/UpdatePerson',
                deleteAction: '/GettingStarted/DeletePerson'
            },
            fields: {
                PersonId: {
                    key: true,
                    list: false
                },
                Name: {
                    title: 'Author Name',
                    width: '40%'
                },
                Age: {
                    title: 'Age',
                    width: '20%'
                },
                RecordDate: {
                    title: 'Record date',
                    width: '30%',
                    type: 'date',
                    create: false,
                    edit: false
                }
            }
        });
    });
</script>
</head>
<body>
<div id="PersonTableContainer"></div>
</body>
</html>

【问题讨论】:

  • 您的页面是否可以访问 jquery.jtable.min.js ?
  • @NoobUnChained 是的,看我有 test folder.inside test folder index.html 和 jtable 文件夹。在 jtable 里面我有 jquery.jtable.min.js
  • 在 Firebug 或 Chrome 的调试器控制台中是否出现任何错误?
  • @NoobUnChained 不,我只是得到一个空白页
  • 你是否包含了 jquery 库?

标签: jquery jsp servlets jtable


【解决方案1】:

<html>
<head>

<script src="https://raw.github.com/akashshinde/project/master/scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="https://github.com/akashshinde/project/raw/master/scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>

<!-- Include one of jTable styles. -->

<link href="https://raw.github.com/akashshinde/project/master/themes/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<link href="https://raw.github.com/akashshinde/project/master/scripts/jtable/themes/lightcolor/blue/jtable.css" rel="stylesheet" type="text/css" />

<!-- Include jTable script file. -->
<script src="https://raw.github.com/akashshinde/project/master/scripts/jtable/jquery.jtable.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
    $('#PersonTableContainer').jtable({
        title: 'Table of people',
        actions: {
            listAction: '/GettingStarted/PersonList',
            createAction: '/GettingStarted/CreatePerson',
            updateAction: '/GettingStarted/UpdatePerson',
            deleteAction: '/GettingStarted/DeletePerson'
        },
        fields: {
            PersonId: {
                key: true,
                list: false
            },
            Name: {
                title: 'Author Name',
                width: '40%'
            },
            Age: {
                title: 'Age',
                width: '20%'
            },
            RecordDate: {
                title: 'Record date',
                width: '30%',
                type: 'date',
                create: false,
                edit: false
            }
        }
    });
});
</script>
</head>
<body>
<div id="PersonTableContainer"></div>
</body>
</html>

实际上 javascript 文件没有正确加载到您的 jsp 文件中 所以在 url 中正确导航 .js 文件,就像我在上面的代码中输入的那样。

Just replace code with your code

【讨论】:

  • 你能解释一下你做了什么不同的事情,以便 Op 可以理解这个概念,而不是复制代码!!!
  • @akash shinde 相同的空白页
  • @NoobUnChained ,我只是参考jTable作者给出的示例
  • @javaL ,由于 jTable 使用 ajax ,所以您需要从 javascript 加载 ajax 请求,因此我添加了代码以将 Ajax 请求加载到 div->PersonTableContainer
  • @javaL,你能给我们你的项目文件夹链接,以便我可以测试它
【解决方案2】:

好像您没有包含 jQuery 库,请尝试将其放在您的 jtable 链接之前:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" 
        type="text/javascript"></script>

【讨论】:

  • @Nooob Unchained 请查看我编辑的问题,我已将其包括在内
  • @javaL 您需要将引用的 jQuery 库放在引用的 jtable 脚本之前
  • 对不起上一篇文章,我已经按照你说的做了,但仍然没有得到想要的输出。我只是得到空白页。你知道我可以使用的任何其他开源 jquery jtable。提前谢谢
  • 我必须做一个约会页面,其中将包含姓名、开始时间、结束时间等,因此您建议的站点没有输入新记录的选项。我帖子中的链接最适合我的要求,因为它有一个添加新条目的选项,当您单击它时,它将反映在同一页面中。
猜你喜欢
  • 2015-11-20
  • 2013-03-27
  • 2021-07-08
  • 1970-01-01
  • 2016-12-04
  • 2013-08-05
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多