2016-09-09 32 views
0

這是我的Ajax調用:錯誤與我的春節控制器

$.ajax({ 
    type: "GET", 
    url: "/support-web/downloadCSV.json", 
    data:jsonfile, 
    dataType:"json", 
    success: function (data) { 
     console.log("SUCCESS") 
    } 
}); 

這是我的控制器:

@Controller 
@RequestMapping(value = "/downloadCSV") 
public class DownloadCSVController { 
    @RequestMapping(method = RequestMethod.GET) 
    @ResponseBody 
    public void downloadCSV(HttpServletRequest request, HttpServletResponse response, @RequestParam String json) 
      throws IOException { 
    ... 
    } 
} 

我有這樣的錯誤:

http://localhost:8080/support-web/downloadCSV?json=%5B%22http%3A%2F%2Fmapsr …ERSION%3D1.1.0%26OUTPUTFORMAT%3DCSV%26TYPENAME%3DP_GIS_OBSLITHO_MEXP%22%5D 404 (Introuvable)

回答

0

嘗試這樣

@Controller 
    public class DownloadCSVController {  
      @RequestMapping(@RequestMapping(value = "/downloadCSV")", method=RequestMethod.GET) 
      @ResponseBody 
      public void downloadCSV(HttpServletRequest request, HttpServletResponse response, @RequestParam String json) 
        throws IOException { 
      ... 
      } 
+0

工作不相同的錯誤 – Mercer

0

你正在一個Ajax請求

"/support-web/downloadCSV.json" 

但你的控制器只有@RequestMapping(value = "/downloadCSV")

@Controller 
@RequestMapping(value = "/support-web") 
public class DownloadCSVController { 
    @RequestMapping(value = "/downloadCSV", method = RequestMethod.GET) 
    @ResponseBody 
    public void downloadCSV(HttpServletRequest request, HttpServletResponse response, @RequestParam String json) 
      throws IOException { 
    ... 
    } 
} 

而變化Ajax調用

$.ajax({ 
    type: "GET", 
    url: "/support-web/downloadCSV", 
    data: "json=" + jsonfile, 
    success: function (data) { 
     console.log("SUCCESS") 
    } 
}); 
+0

工作不相同的錯誤 – Mercer

+0

嘗試將ajax調用中的url更改爲「/ support-web/downloadCSV」並刪除數據類型:json – Janar

+0

有相同的錯誤 – Mercer