Fw: [問題] 明明有進入程式裡的方法,頁面卻跳出404已刪文

看板Web_Design作者 (= =)時間3年前 (2020/07/27 22:18), 3年前編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
※狀況概述: 就是我透過spring和JQuery ajax,寫了一個簡單的動態下拉式選單的程式, 我在瀏覽器上輸入url,在debugger模式下可以看到執行緒停留在中斷點的位置, 但是瀏覽器卻顯示404,而我在程式裡撈的資料也沒有回到前端,也就是 前端的回呼函數沒有接到撈出來的資料。 ※程式碼: 前端: $(document).ready(function(){ $("#dropdown1").change(function() { //alert("ajax"); $.ajax({ type :"GET", url : "/TestSpringJQueryAjax1/goToTestController.do?method=queryCountry", data : { continentId : $("#dropdown1").val(), }, dataType: "json", mmsuccess : function(data) { //alert(data.list[0].countryId); //var i = 0; $("#dropdown2 option").remove(); data.list.forEach(function(value,index){ $("#dropdown2").append(new Option(data.list[index].countryName, data.list[index].countryId)); //i++; }); }, error:function(data){ alert(data); } }) }) }); 後端: @ResponseBody public String queryCountry(HttpServletRequest request, HttpServletResponse response) { String continentId = request.getParameter("continentId"); List<Country> list = testDao.queryCountry(continentId); Map<String, Object> resultMap = new HashMap<String, Object>(); resultMap.put("list", list); Gson gson = new Gson(); String result = gson.toJson(resultMap); return result; } ※錯誤訊息: http://localhost:8080/TestSpringJQueryAjax1/goToTestController.do ?method=queryCountry&continentId=2 404 (Not Found) 所以現在卡在為何明明有進入到程式裏面,卻仍然跳404錯誤, 而且後端撈出來的資料沒有回到前端的回呼函數。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.162.208.115 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/java/M.1595859040.A.78A.html ※ 編輯: lueichun (1.162.208.115 臺灣), 07/27/2020 22:19:43
文章代碼(AID): #1V7k9JRX (Web_Design)
文章代碼(AID): #1V7k9JRX (Web_Design)