0

私のjqgridはまったく表示されません。私はこれが初めてなので、説明をいただければ幸いです。私のページは以下にあり、私が知る限り、必要なファイルなどはすべてあり、Chrome で 404ed になっているものはありません。Spring で Eclipse を使用していることを付け加えておきます。Chrome で表示されるエラーは、下部のページ情報に従います。それらはほんの数個の構文エラーのように見えますが、私は欺瞞的だと感じています。

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
    <link rel="stylesheet" type="text/css" media="screen" href="resources/jqgrid/css/smoothness/ui-lightness/jquery-ui-1.10.0.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="resources/jqgrid/css/ui.jqgrid.css" />

<script type="text/javascript" src="resources/jqgrid/js/jquery/jquery-1.4.2.min.js"></script>
<!--  
<script type="text/javascript">
    var $jq = jQuery.noConflict();
</script>
-->
<script type="text/javascript" src="resources/js/jquery/jquery-ui-1.8.6.custom.min.js"></script> 
<script type="text/javascript" src="resources/jqgrid/js/grid.locale-en.js" ></script>
<script type="text/javascript" src="resources/jqgrid/js/jquery.jqGrid.min.js"></script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

 <script type="text/javascript">
$(function() {
    $("#grid").jqGrid({
        url:'/listgrid',
        datatype: 'json',
        mtype: 'GET',
        colNames:['Title', 'Description', 'Release Year'],
        colModel:[
            {name:'title',index:'title', width:55,editable:false,editoptions:{readonly:true,size:10},hidden:true},
            {name:'description',index:'description', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}},
            {name:'release_year',index:'release_year', width:100,editable:true, editrules:{required:true}, editoptions:{size:10}}
        ],
        postData: { 
        },
        rowNum:20,
        rowList:[20,40,60],
        height: 200,
        autowidth: true,
        rownumbers: true,
        pager: '#pager',
        sortname: 'title',
        viewrecords: true,
        sortorder: "asc",
        caption:"Movies",
        emptyrecords: "Empty records",
        loadonce: false,
        loadComplete: function() {
        },
        jsonReader : {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false,
            cell: "cell",
            id: "id"
        }
    });


});
  </script>


<title>Home</title>
   </head>
   <body>


<h1>
Hello  world!  
</h1>

<P>  The time on the server is ${serverTime}. </P>

<p>JqGrid - Spring 3 MVC Integration Tutorial</p>
<div id="jqgrid">
<table id="grid"></table>
<div id="pager"></div>
</div>
</body>
</html>

そして、私が見ているエラーは次のとおりです。

Resource interpreted as Script but transferred with MIME type text/html:
"http://localhost:8080/movies/resources/jqgrid/js/jquery.jqGrid.min.js". localhost:8
Resource interpreted as Stylesheet but transferred with MIME type text/html:
"http://localhost:8080/movies/resources/jqgrid/css/ui.jqgrid.css". localhost:6
Resource interpreted as Stylesheet but transferred with MIME type text/html:
"http://localhost:8080/movies/resources/jqgrid/css/smoothness/ui-lightness/jquery-ui-1.10.0.custom.css". localhost:5
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/movies/resources/jqgrid/js/jquery/jquery-1.4.2.min.js". localhost:8
 Uncaught SyntaxError: Unexpected token < :8080/movies/resources/jqgrid/js/jquery/jquery-1.4.2.min.js:3
  Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/movies/resources/js/jquery/jquery-ui-1.8.6.custom.min.js". localhost:8 Uncaught SyntaxError: Unexpected token < :8080/movies/resources/js/jquery/jquery-ui-1.8.6.custom.min.js:3
  Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/movies/resources/jqgrid/js/grid.locale-en.js". localhost:8
   Uncaught SyntaxError: Unexpected token < :8080/movies/resources/jqgrid/js/grid.locale-en.js:3
  Uncaught SyntaxError: Unexpected token < jquery.jqGrid.min.js:3
  Uncaught ReferenceError: $ is not defined localhost:21
4

2 に答える 2

1

私自身、Eclipse や Spring は使用していません。だから私はあなたをあまり助けることができません。それにもかかわらず、投稿したコードにいくつかの問題が見られます。たとえば、次のような構造を使用します

<link ... />

<!-- ... -->

コードを XHTML として解釈する必要があると考える理由は何ですか? quirks モードでコードを HTML ではなく XHTML として解釈させるには、前に!DOCTYPE を追加する必要があります。たとえば、含めることができます <html>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
          "http://www.w3.org/TR/html4/strict.dtd">

その後、JavaScript コードを常に と の間に配置することをお勧めし//<![CDATA[ ます//]]>

<script type="text/javascript">
//<![CDATA[
$(function() {
....
//]]>
</script>

この場合、XHTML ページに任意のJavaScript コードを含めることができます。

さらに、異なるバージョンの jQuery UI を混在させて使用することは非常によくありません。と併用jquery-ui-1.10.0.custom.cssjquery-ui-1.8.6.custom.min.jsます。さらに、非常に古いバージョンの jQuery ( jquery-1.4.2.min.js) を使用しています。どのバージョンの jQuery UI でサポートされるかを正確に読む必要があります。たとえば、jQuery UI 1.10.0 および jQuery UI 1.9.2 は、バージョン 1.6 以降の jQuery をサポートします。古い 1.4.2 バージョンの jQuery を本当に使用する必要がある場合は、jQuery UI 1.8.x を使用する必要があります。この場合、 jQuery UI 1.8.24を使用することをお勧めします。

私自身、Eclipse や Spring は使用していません。そのため、間違った MIME タイプ text/html を設定する問題については、これ以上お手伝いできません。正しく機能しているコードと、問題のある現在のコードをより注意深く比較する必要があります。または、stackoverflow で新しい質問をする必要がありますが、別のタグを使用してください。

于 2013-01-30T08:16:59.643 に答える
0

構文エラーがあります。通常、これにより他のスクリプトが意図したとおりに実行されなくなります。エラーを修正すると、運が良くなる可能性があります。

于 2013-01-29T22:39:01.510 に答える