Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SpringDataREST使用哪种方法从查询参数中提取实体?_Spring_Spring Boot_Spring Data Rest - Fatal编程技术网

SpringDataREST使用哪种方法从查询参数中提取实体?

SpringDataREST使用哪种方法从查询参数中提取实体?,spring,spring-boot,spring-data-rest,Spring,Spring Boot,Spring Data Rest,例如,我们有这样一个请求: GET /orders/search { "user": "http://example.org/users/1", ... } SpringDataREST以何种方式从URL检索用户实体?它是否使用正则表达式检索id 1,然后查询它或其他什么?如果您想了解spring数据存储库,您需要使用此方法 User=userRepository.findById(整数id) 不幸的是,这不是我想知道的。从上面的请求中,

例如,我们有这样一个请求:

GET /orders/search
{
    "user": "http://example.org/users/1",
    ...
}

SpringDataREST以何种方式从URL检索用户实体?它是否使用正则表达式检索id 1,然后查询它或其他什么?

如果您想了解spring数据存储库,您需要使用此方法


User=userRepository.findById(整数id)

不幸的是,这不是我想知道的。从上面的请求中,Spring Data Rest神奇地转动
“用户”:http://example.org/users/1“
发送到用户实体。我想你的代码是它的最后一部分。但是Spring数据Rest使用哪种方法来转换
http://example.org/users/1“
url到
Integer id
以便它可以使用
findById
方法?我想您正在寻找控制器,对吗?如果是,这将是控制器映射@GetMapping(“/users/{id})公共用户getUserById(@PathVariable Integer id){//返回服务调用以从存储库获取用户。}我想您没有看透我的问题。这里的端点是
/orders/search
,请求主体是
{“User”:http://example.org/users/1" }
方法处理程序将有如下内容
findOrderByUser(User User);
问题是,Spring Data Rest如何从Url获取用户实体?不太可能发出另一个get请求,因为它效率很低,而且
@GetMapping(“/users/{id}”)会
returns通常不再是用户实体,而是经过修改的实体。