Ajax向后台传数据,一直报Failed to load resource: the server responded with a status of 404 (Not Found)错误

jsp页面ajax:

  $.ajax({
                type: "post",
                url: "servicePage.do",
                dataType: "json",
                contentType: "application/json", //前端向后台发送json数据时要声明
                data: d,
                success: function (data) {
                    alert(data)
                },
                error: function () {
                    alert("失败")
                }
            })

controller接收:

@RequestMapping(value = "servicePage.do",method = RequestMethod.POST)
    @ResponseBody
    public ServicePage service2(@RequestBody ServicePage servicePage, Model model){
        ServicePage servicePage1 = myService.queryService(servicePage);
        model.addAttribute("servicePage",servicePage1);
        return servicePage1;
    }

一开始以为路径写错了,复制粘贴后还是报错

上百度查,挨个改法尝试依然不得其果

 

最后将target删除重新启动就好了!

主要是idea在重新编译时出现问题了

你可能感兴趣的:(Ajax向后台传数据,一直报Failed to load resource: the server responded with a status of 404 (Not Found)错误)