报错: required string parameter XXX is not present

@RequestParam

  • jQuery调用方式:
    deleteFile: function(filePath) {
        return ajax({
            method: 'POST',
            url: '/cm/soft/package/package/deleteFile',
            data: {
                fileDir: filePath
            }
        });
    },
  • 后台java controller形式
    public BaseResultVO deleteFile(@RequestParam("fileDir") String fileDir) {}

@PathVariable

  • jQuery调用方式
    savePackage: function(obj, packageId) {
        var url = "/cm/soft/package/package/" + packageId;
        return ajax({
            method: 'POST',
            url: url,
            data: obj,
        });
    }
  • 后台java controller形式
    public BaseResultVO delete(@PathVariable String packageid) {}

报错:required string parameter XXX is not present

  • jquery提交delete时,不支持@RequestParam,只支持@PathVariable形式
  • 若api在调用的时候,如果存在重类型,但不重名;例如:/id与/name,两者在类型上是一样的

你可能感兴趣的:(javaweb,错误及乱码解决)