0

我收到一个带有 jquery 部分和几个脚本导入以及图像导入的 JSP 页面的错误。每当我使用 POST 方法时,JSP 也会尝试添加 jquery 脚本。我收到错误

Failed to load resource: the server responded with a status of 405 (Method Not Allowed)        http://localhost:8080/risk/add/jQuery.js

我需要从 post 方法中专门排除 jquery 吗?还是我需要在其他地方导入我的 jquery 脚本?

编辑:

<%@ page import="game.model.Game" %>
<%@ page import="players.model.Player" %>
<%@ page import="territories.model.Territory" %>
<%@ page import="java.util.*" %>
<%@ page import="java.util.*" %>

<% Game game = (Game)request.getAttribute("game"); %>
<% ArrayList<Player> players = new ArrayList<Player>(); %>
<% players = game.getPlayers(); %>
<html>
<script language="javascript" src="jQuery.js"></script>
<script language="javascript" src="jQuery.imagemapster.js"></script>
<script language="javascript" src="jquery.rwdImageMaps.js"></script>

<style type="text/css">
    #wrap {
       width:1500px;
    }
    #left_col {
       float:left;
       width:1200px;
    }
    #right_col {
       float:right;
       width:300px;
    }
</style>
<head>
    <title>
        Risk
    </title>
    <h1>
        Risk
    </h1>
    <h2>
        Players, Armies, and Territories
    </h2>
<div id="wrap">
<div id="left_col">
<img src="gui/map.png" width="1200" height="850" alt="map" usemap="#worldmap" id = "map">
<map name="worldmap">
    <area shape="poly" coords="150,377,142,338,111,313,114,255,48,234,18,264,12,289,24,366,166,402,150,377" href="#" name="Alaska" title="Alaska"   />
    <area shape="poly" coords="113,259,108,247,111,309,145,335,263,338,302,360,311,333,316,310,336,314,367,321,375,271,315,190,331,132,383,47,330,29,250,71,225,112," href="#" name="Northwest Territory" title="Northwest Territory"   />
    <area shape="poly" coords="240,406,240,338,143,336,151,363,152,385,173,403," href="#" name="Alberta" title="Alberta"   />
    <area shape="poly" coords="240,339,265,341,300,361,312,386,314,422,324,426,310,436,301,434,301,415,284,403,274,409,268,407,240,405," href="#" name="Ontario" title="Ontario"   />
    <area shape="poly" coords="313,423,332,423,342,414,360,427,394,411,409,401,397,370,375,341,363,328,353,338,344,326,329,314,314,312,311,368,313,413," href="#" name="Quebec" title="quebec"   />     <area shape="poly" coords="165,404,266,406,267,443,244,464,236,466,240,476,218,480,204,467,184,467,163,441," href="#" name="Western United States" title="Western United States"   />
    <area shape="poly" coords="238,477,237,464,249,450,268,444,272,409,285,402,300,419,303,434,321,428,340,415,346,425,340,436,324,450,308,476,314,500,292,480,255,489," href="#" name="Eastern United states" title="Eastern United States"   />
    <area shape="poly" coords="185,467,209,509,257,533,304,561,315,555,300,546,302,530,286,528,292,508,273,513,260,519,253,493,237,480,203,469," href="#" name="Mexico" title="Mexico"   />
    <area shape="poly" coords="435,335,398,293,392,231,349,185,331,149,377,64,463,24,543,87,506,250,450,295," href="#" name="Greenland" title="Greenland"   />
    <area shape="poly" coords="316,578,342,583,343,569,358,571,356,561,388,572,392,562,380,548,341,541,317,552," href="#" name="Venezuela" title="Venezuela"   />
    <area shape="poly" coords="311,577,333,583,341,611,351,606,381,627,386,650,384,661,392,687,339,667,304,604," href="#" name="Peru" title="Peru"   />
    <area shape="poly" coords="340,669,406,708,387,817,304,808,335,684," href="#" name="Argentina" title="Argentina"   />
    <area shape="poly" coords="333,584,395,560,471,607,403,709,382,659,382,634,353,608," href="#" name="Brazil" title="Brazil"   />
    <area shape="poly" coords="499,281,536,280,517,311,495,298," href="#" name="Iceland" title="Iceland"   />
    <area shape="poly" coords="543,381,547,355,566,331,588,374,575,389,557,393," href="#" name="Great Brittain" title="Great Brittain"   />
    <area shape="poly" coords="588,384,565,395,549,420,548,451,561,455,584,446,601,425,600,396," href="#" name="Western Europe" title="Western Europe"   />
    <area shape="poly" coords="588,384,613,401,627,386,639,405,659,382,648,360,618,363,616,344,603,351,592,371," href="#" name="Northern Europe" title="Northern Europe"   />
    <area shape="poly" coords="604,423,609,442,631,453,666,463,666,437,677,433,681,411,661,389,660,381,646,406,636,407,631,383,627,383,627,398,605,402," href="#" name="Southern Europe" title="Southern Europe"   />
    <area shape="poly" coords="624,357,614,339,601,345,592,311,641,251,675,228,684,247,676,329,657,333," href="#" name="Scandanavia" title="Scandanavia"   />
    <area shape="poly" coords="652,362,653,344,675,328,687,251,785,253,810,268,806,379,737,390,733,418,745,437,744,443,719,430,707,418,683,414,659,382," href="#" name="Ukraine" title="Ukraine"   />
    <area shape="poly" coords="559,455,521,503,524,550,574,576,613,577,626,577,625,558,645,538,643,517,609,508,603,468,613,455,588,454," href="#" name="North Africa" title="North Africa"   />
    <area shape="poly" coords="616,467,610,475,613,501,645,511,654,500,690,500,684,478,652,470," href="#" name="Egypt" title="Egypt"   />
    <area shape="poly" coords="615,582,632,581,631,558,648,543,659,562,682,567,670,584,672,603,666,619,652,616,645,600,615,594," href="#" name="Central Africa" title="Central Africa"   />
    <area shape="poly" coords="621,602,629,627,624,646,630,710,676,716,700,663,712,622,696,627,694,641,687,640,681,620,674,614,672,632,648,624,639,605," href="#" name="South Africa" title="South Africa"   />
    <area shape="poly" coords="691,620,714,619,716,606,755,547,732,547,711,525,698,502,656,504,650,515,655,540,685,563," href="#" name="East Africa" title="East Africa"   />
    <area shape="poly" coords="723,668,725,646,742,628,755,634,742,670,733,681," href="#" name="Madagascar" title="Madagascar"   />
    <area shape="poly" coords="725,546,783,513,790,496,782,463,754,455,723,435,692,431,673,437,682,453,705,449,698,479,724,526," href="#" name="Middle East" title="Middle East"   />
    <area shape="poly" coords="738,412,740,393,809,387,806,319,855,404,820,437,785,455,766,447,761,403," href="#" name="Afghanistan" title="Afghanistan"   />
    <area shape="poly" coords="859,402,813,313,815,288,808,244,818,224,852,324,845,364,863,384," href="#" name="Ural" title="Ural"   />
    <area shape="poly" coords="867,402,884,404,885,374,915,367,936,378,945,394,948,361,959,297,944,281,965,252,967,221,954,107,913,71,823,198,830,254,858,321,855,366,869,382," href="#" name="Siberia" title="Siberia"   />
    <area shape="poly" coords="964,338,968,294,956,285,969,270,975,174,1067,158,1091,194,1065,229,1049,291,1029,332,1001,322," href="#" name="Yakutsk" title="Yakutsk"   />
    <area shape="poly" coords="1071,222,1191,233,1185,315,1107,386,1053,363,1026,358,1050,299,1066,310,1069,292," href="#" name="Kamtchaka" title="Kamtchaka"   />
    <area shape="poly" coords="888,403,896,384,915,380,931,384,948,401,955,391,957,358,1000,337,1022,336,1024,366,1033,393,1017,375,983,399," href="#" name="Irkutsk" title="Irkutsk"   />
    <area shape="poly" coords="1057,363,1073,403,1062,440,1020,479,1011,464,1049,436,1052,410," href="#" name="Japan" title="Japan"   />
    <area shape="poly" coords="883,418,887,406,970,406,1010,392,1019,380,1027,396,1023,417,1014,457,1001,459,998,440,964,431," href="#" name="Mongolia" title="Mongolia"   />
    <area shape="poly" coords="793,491,786,460,816,453,845,481,894,484,886,517,848,575,813,516," href="#" name="India" title="India"   />
    <area shape="poly" coords="905,488,891,511,894,534,916,569,933,581,949,543,948,513,935,503,915,506," href="#" name="Siam" title="Siam"   />
    <area shape="poly" coords="831,454,833,438,856,409,875,408,886,426,975,440,992,495,948,513,912,488,900,478,855,474," href="#" name="China" title="China"   />       <area shape="poly" coords="899,571,947,623,1004,623,1038,608,1038,583,990,518,974,525,941,582," href="#" name="Indonesia" title="Indonesia"   />
    <area shape="poly" coords="1040,616,1056,583,1103,601,1087,627," href="#" name="New Guinea" title="New Guinea"   />
    <area shape="poly" coords="1009,631,956,661,962,716,1054,726,1050,668,1011,665," href="#" name="Western Australia" title="Western Australia"   />
    <area shape="poly" coords="1015,636,1016,662,1054,664,1058,748,1089,757,1103,671,1060,621,1019,627," href="#" name="Eastern Australia" title="Eastern Australia"   />   
</map>
    </div>
    <div id="right_col">
    <div style="float: right; width: 300px; height: 850px; font-size:40px; border: 1px solid black;" id="selection"></div>
    </div>
</div>
<script language = "javascript">
$(document).ready(function ()
{
$('#map').mapster({
singleSelect : true,
render_highlight : { altImage : 'gui/map2.gif' },
 mapKey: 'name',
fill : true, altImage : 'gui/map1.gif',
fillOpacity : 1,
});
});
</script>
<script language = "javascript">    

$(document).ready(function(e) {

$('img[usemap]').rwdImageMaps();
$('area').on('mouseover', function() {
    var territory = $(this).attr('name');

    $('#selection').html(territory);
});
});
</script>
    <h3>
        <% while (game.getActivePlayer().getArmies() == 0)
        {
            if (game.allInitialArmiesAllocated())
            {
                game.endTurn();
                break;
            }
            game.endTurn();
        } %>
        <% if (!game.allInitialArmiesAllocated()) { %>
            <%= game.getActivePlayer().getName() %> allocate an army
        <% } %>
        <% if (game.allInitialArmiesAllocated()) { %>
            <%= game.getActivePlayer().getName() %> proceed next with turn
        <% } %>
    </h3>
    <table border="5">
        <% for (Player player: players) { %>
        <tr>
            <td><%= player.getName() %> (<%= player.getArmies() %> Armies)</td>
            <% for (Territory territory: player.getTerritories()) { %>
            <td>
            <%= territory.getName() %> (<%= territory.getArmies() %>)
            <% if (game.allInitialArmiesAllocated() == false) { %>
                    <% if ((player.getName()).equalsIgnoreCase(game.getActivePlayer().getName()) && player.getArmies() > 0) { %>
                        <form action="/risk/add/<%= territory.getName() %>" method="POST">
                        <input type="hidden" name="operation" value="add"/>
                        <input type="submit" value="Add Army"/>
                        </form>
                    <% } %>
            <% } %>
            </td>
            <% } %>
        </tr>
        <% } %>
    </table>
    <% if (game.allInitialArmiesAllocated()) { %>
        <form action="/risk/firstGameTurn" method="POST">
        <input type="hidden" name="operation" value="proceedWithTurn" />
        <input type="submit" value="Proceed With Turn" />
        </form>
    <% } %>
    </head>
</html>
4

1 回答 1

0

在 HEAD TAG 中写入以下代码

<script language="javascript" src="jQuery.js"></script>
<script language="javascript" src="jQuery.imagemapster.js"></script>
<script language="javascript" src="jquery.rwdImageMaps.js"></script>

<style type="text/css">
    #wrap {
       width:1500px;
    }
    #left_col {
       float:left;
       width:1200px;
    }
    #right_col {
       float:right;
       width:300px;
    }
</style>
于 2013-08-28T17:17:02.363 回答