Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript sortable.js在JSP页面中不起作用_Javascript_Jsp - Fatal编程技术网

Javascript sortable.js在JSP页面中不起作用

Javascript sortable.js在JSP页面中不起作用,javascript,jsp,Javascript,Jsp,我正在尝试使用我找到的这个小脚本,但由于某种原因它不起作用,我不知道为什么 browse.jsp中的我的头部标记: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Parcourir les livres</title> <script type="text/javascript" src="../../

我正在尝试使用我找到的这个小脚本,但由于某种原因它不起作用,我不知道为什么

browse.jsp中的我的头部标记:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Parcourir les livres</title>
    <script type="text/javascript" src="../../JS/sortable.js"></script>
</head>
我的表格,当然在同一页:

    <table class="sortable" id="sortabletable">          
            <thead>
                    <th>Aperçu</th>
                    <th>Titre</th>
                    <th>Éditeur</th>
                    <th>Auteur</th>
                    <th>Prix</th>
            </thead>
            <%
            for(Livre livre : livres){
                 %>
                <tr>
                    <td>Image</td>
                    <td><% out.println(livre.getNom()); %></td>
                    <td><% out.println(livre.getEditeur()); %></td>
                    <td><% out.println(livre.getAuteur()); %></td>
                    <td><% out.println(livre.getPrix()); %></td>
                </tr>
            <% } %>
  </table>
我不认为它来自src路径,因为我试图将.js放在与我的页面相同的目录中。不管怎样,这是我的


谢谢

可能您的javascript路径是错误的。如果不了解您的应用程序,我无法为您提供确切的路径

它可能是JS/sortable.JS或../JS/sortable.JS。无法直接访问WEB-INF目录中的文件。因此,您不必从项目结构中找出路径。您必须在运行时从路径中找出它

您也可以尝试使用绝对路径

<script type="text/javascript" src="<%=request.getContextPath()%>/JS/sortable.js" />

嗯,你的错误控制台怎么说?没什么。脚本的行为就像它不在这里一样。是否需要调用任何函数才能使其工作?我不熟悉你正在使用的脚本。根据脚本作者的说法,不,我不熟悉。只需放入脚本并向要排序的表添加class和id属性……奇怪。您可以尝试将排序脚本放在页面底部,但除此之外,我不知道该建议什么。抱歉:CI尝试了你们三个路径,但都不起作用。。。尽管path在getContextPath方法中看起来不错,它给了我src=/Javaxia/JS/sortable.JS。无论如何,在我的第一篇文章中,我在Netbeans中包含了一个项目屏幕。请尝试绝对路径。如果该页面不起作用,请发布调用javascript的页面的完整路径和javascript的完整路径。尝试将呈现页面中的完整路径调用到浏览器中。如果该路径正常工作,则可能是使用问题。您应该检查javascript是否已部署。尝试将文件夹重命名为js,并使路径小写。您使用的是什么应用程序服务器?你能访问css文件吗?小写技巧不起作用。我使用Glassfish 3.1.1,似乎我也无法访问CSS文件。我的项目可能会搞砸。。。