spring date rest方法中复杂参数的传递方式 [英] The way of passing complex params into spring date rest's method

查看:41
本文介绍了spring date rest方法中复杂参数的传递方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找有关以下问题的任何信息:我有一个 JPA 存储库,它通过 Spring Data Rest 项目暴露给 REST 服务:

I am trying to find any info regarding the following issue: I have a JPA repository which was exposed to REST service with Spring Data Rest project:

Page<Business> findByUser(@Param("user") User user, Pageable pageable);

其中 user 参数是实体.

现在,当我尝试从客户端(使用 RestTemplate 或 Traverson)调用这个 REST 方法时,我不明白我应该如何传递这个参数...

Now when I try to call this REST method from client (with RestTemplate or Traverson) I can't understand how should I pass this param...

是否可以在不制作自定义控制器的情况下实现它?

Is it possible to implement it without making custom controller?

提前致谢

推荐答案

我终于想通了.查看 Spring JIRA 上的这个问题.

I finally figured it out. Look at this issue on Spring JIRA.

请求方式取决于您的 Spring Data Rest 版本.如果您使用的是 2.4+ 版本,则必须使用 URI.如果您有旧版本,则必须使用主键.

The way to request this depends on your version of Spring Data Rest. If you have a version 2.4+, you have to use the URI. If you have an older version, you have to use the primary key.

因此,如果您有旧版本的 SDR,您可能需要公开主键.这个问题可以帮助您解决这个问题.

So you may need to expose your primary keys if you have an older version of SDR. This question could help you in managing that.

这篇关于spring date rest方法中复杂参数的传递方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆