其他分享
首页 > 其他分享> > 记一次 SpringCloud OpenFeign 服务间调用传参异常

记一次 SpringCloud OpenFeign 服务间调用传参异常

作者:互联网

错误方式:

    /**
     * 参与方Controller中:更新角色缓存
     */
    @PostMapping(value = "/cacheSysUserRole")
    public Result<?> cacheSysUserRole(@RequestParam("userRoleList") List<SysUserRole> userRoleList) {
        cacheService.cacheSysUserRole(userRoleList);
        return success();
    }
    /**
     * 调用方Feign接口中:更新角色缓存
     *
     * @param userRoleList List<SysUserRole>
     * @return Result<?>
     */
    @PostMapping(value = "/gateway/gateway-cache/cacheSysUserRole")
    Result<?> cacheSysUserRole(@RequestParam("userRoleList") List<SysUserRole> userRoleList);

正确方式:

    /**
     * 参与方Controller中:更新角色缓存
     */
    @PostMapping(value = "/cacheSysUserRole")
    public Result<?> cacheSysUserRole(@RequestBody List<SysUserRole> userRoleList) {
        cacheService.cacheSysUserRole(userRoleList);
        return success();
    }
    /**
     * 发起方Feign接口中:更新角色缓存
     *
     * @param userRoleList List<SysUserRole>
     * @return Result<?>
     */
    @PostMapping(value = "/gateway/gateway-cache/cacheSysUserRole")
    Result<?> cacheSysUserRole(@RequestBody List<SysUserRole> userRoleList);

总结:方法使用@PostMapping,参数使用@RequestBody。

标签:传参,OpenFeign,SpringCloud,cacheSysUserRole,value,PostMapping,Result,userRoleList,
来源: https://www.cnblogs.com/mizepeng/p/16075399.html