gpt4 book ai didi

JQuery 数据表不工作

转载 作者:行者123 更新时间:2023-12-01 04:56:47 25 4
gpt4 key购买 nike

我是 JQuery 新手。我正在尝试创建一个数据表,但它不起作用。除数据表功能外,所有功能均有效。也就是说,表格显示了正确的数据,但排序、分页等不起作用。我已将下载的插件代码中的媒体和脚本文件夹复制到我的 webapp 文件夹中。请让我知道可能出了什么问题。我已经从此链接下载了数据表插件 http://www.codeproject.com/Articles/359750/jQuery-DataTables-in-Java-Web-Applications

下面是我的jsp文件

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/jsp/common/include.jsp"%>
<%@ page import ="java.util.Date" %>
<html>
<head>
<title>Subscriptions List</title>
<link href="${RESOURCE_ROOT}/css/usersubs.css" rel="stylesheet" type="text/css" />
<link href="/media/dataTables/demo_page.css" rel="stylesheet" type="text/css" />
<link href="/media/dataTables/demo_table.css" rel="stylesheet" type="text/css" />
<link href="/media/dataTables/demo_table_jui.css" rel="stylesheet" type="text/css" />
<link href="/media/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" media="all" />
<link href="/media/themes/smoothness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" media="all" />

<script src="/scripts/jquery.js" type="text/javascript" ></script>
<script src="/scripts/jquery.dataTables.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function () {
$("#subscriptionlist").dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": true
});
});
</script>
</head>
<body>
<div id="subscriptionsList">
<table id="subscriptionlist">
<thead>
<tr>
<th>Subscription Name</th>
<th>Type</th>
<th>Last Updated</th>
<th>Creation Date</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<c:forEach var="subscription" items="${subList}">
<tr>
<td>${subscription.name}</td>
<td>${subscription.type}</td>
<td>${subscription.lastUpdateDt}</td>
<td>${subscription.createDt}</td>
<td><a href="${CONTEXT_ROOT}subscription/delete/id/${subscription.id}/${subscription.user.id}" class="show-hand-cursor">Delete</a></td>
</tr>
</c:forEach>
</tbody>
</table>
<div style="width:100%; margin-top:0px;">
<table border="0px">
<tr>
<td style="padding-top:25px"; align="right" class="noborder"> <button >Add Subscription</button></td>
</tr>
</table>
</div>
<div>

</div>
</div>
</body>
</html>

我得到的 HTML 如下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<?xml version="1.0" encoding="UTF-8" ?>
<html>
<head>
<title>Subscriptions List</title>
<link href="/cv-subscription-web/resources/css/usersubs.css" rel="stylesheet" type="text/css" />
<link href="/media/dataTables/demo_page.css" rel="stylesheet" type="text/css" />
<link href="/media/dataTables/demo_table.css" rel="stylesheet" type="text/css" />
<link href="/media/dataTables/demo_table_jui.css" rel="stylesheet" type="text/css" />
<link href="/media/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" media="all" />
<link href="/media/themes/smoothness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" media="all" />

<script src="/scripts/jquery.js" type="text/javascript" ></script>
<script src="/scripts/jquery.dataTables.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function () {
$("#subscriptionlist").dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": true
});
});
</script>
</head>
<body>
<div id="subscriptionsList">
<table id="subscriptionlist">
<thead>
<tr>
<th>Subscription Name</th>
<th>Type</th>
<th>Last Updated</th>
<th>Creation Date</th>
<th>Delete</th>
</tr>
</thead>
<tbody>

<tr>
<td>EQ549_author3</td>
<td>EqWireArticle</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td><a href="/cv-subscription-web/subscription/delete/id/50c0b59781ce4dd6efab7e14/dd32261" class="show-hand-cursor">Delete</a></td>
</tr>

<tr>
<td>EQ549_author4</td>
<td>EqWireArticle</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td><a href="/cv-subscription-web/subscription/delete/id/50c5f96581ce1243814edb11/dd32261" class="show-hand-cursor">Delete</a></td>
</tr>

<tr>
<td>EQ_author7</td>
<td>EqWireArticle</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td><a href="/cv-subscription-web/subscription/delete/id/50c64dc181ce1243814edb14/dd32261" class="show-hand-cursor">Delete</a></td>
</tr>

<tr>
<td>EQ_author6</td>
<td>EqWireArticle</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td><a href="/cv-subscription-web/subscription/delete/id/50c64dc481ce1243814edb15/dd32261" class="show-hand-cursor">Delete</a></td>
</tr>

<tr>
<td>EQ_author8</td>
<td>EqWireArticle</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td>Wed Nov 07 02:46:20 EST 2012</td>
<td><a href="/cv-subscription-web/subscription/delete/id/50c64dc981ce1243814edb16/dd32261" class="show-hand-cursor">Delete</a></td>
</tr>

</tbody>
</table>
<div style="width:100%; margin-top:0px;">
<table border="0px">
<tr>
<td style="padding-top:25px"; align="right" class="noborder"> <button >Add Subscription</button></td>
</tr>
</table>
</div>
<div>

</div>
</div>

</body>
</html>

非常感谢!

最佳答案

我建了一个 fiddle here这很好——我在代码中没有看到 dataTables.css ,但这不会影响功能。

最可能的原因是找不到您的 dataTables.min.js 文件。如果您在修复此问题时遇到问题,您可以尝试链接到数据表的 Microsoft CDN:http://datatables.net/blog/Microsoft_CDN

关于JQuery 数据表不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13825821/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com