$.get请求不到controller

@RequestMapping(value = "getProduce/{id}",method = RequestMethod.GET)
    @ResponseBody
    public Produce getProduce(@PathVariable Integer id)throws JsonProcessingException {
        Produce produceDetails = produceDao.getProduceDetails(id);
        return produceDetails;
    }
$table.on("click", "a.edit", function () {
            alert("asdasd");
            $.get("security/maintenance/getProduce/"+$(this).attr("id"),function (data) {
                var data = JSON.parse(data);
                $("#title").val(data.title);
                $("#create_time").val(data.create_time);
                $("#picture").val(data.picture);
                $("#content").val(data.content);
            },'text'),

            $("#flagDiv").show();
            $.uniform.update();
            $("#modalTitle").html(i18n['editUser']);
            customGlobal.clearFormAndShowDialog("modalDialog");
            $("#dialogForm").validate({
                rules: {
                    username: {
                        required: true
                    },
                    nickname: {
                        required: true
                    },
                }
            })
            $("#addBtn").hide();
            $("#updateBtn").show();
            dataTable.reloadTable();
        });
阅读 3.3k
2 个回答

有没有忘记加@controller 你的参数应该这么写@PathVariable("id") Integer id

其实你在浏览器上的 network 面板上面看一下请求 URL 和请求参数就行,获取不到值,无非就是你没用正确的 key 去获取

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进