Java CURL没有返回所需的响应

Java CURL没有返回所需的响应,java,php,spring,curl,Java,Php,Spring,Curl,我有一个使用Springboot创建的RESTAPI。它在本地内联网上运行良好。 我想远程访问API,所以我在一些托管在公共目录上的PHP页面上使用了CURL。这是唯一允许来自外部请求的连接的目录 问题在于,只有一个SpringREST控制器似乎正在使用PHP页面返回结果 这是我在本地使用邮递员发送请求时得到的结果 我的URL>>http://localIpAddress:8932/springrest/accounts/users/all 结果 [ { "id":

我有一个使用Springboot创建的RESTAPI。它在本地内联网上运行良好。 我想远程访问API,所以我在一些托管在公共目录上的PHP页面上使用了CURL。这是唯一允许来自外部请求的连接的目录

问题在于,只有一个SpringREST控制器似乎正在使用PHP页面返回结果

这是我在本地使用邮递员发送请求时得到的结果

我的URL>>http://localIpAddress:8932/springrest/accounts/users/all

结果

[
{
    "id": 5,
    "email": "si@email.com",
    "password": "pass_",
    "createdAt": "2020-10-14 15:10:29"
},
{
    "id": 6,
    "email": "myemail@email.com",
    "password": "pass_",
    "createdAt": "2020-10-14 15:56:03"
}]
这是我的控制器

@RestController
@RequestMapping(path="/accounts")
public class UserController {
@Autowired
private UserRepository userRepository;

@GetMapping("/users/all")
public @ResponseBody Iterable<User> getAllUsers() {

      return userRepository.findAll();
  }
}
@RestController 
@RequestMapping(path="/faults")
public class AssignedFaultController {
@Autowired 
   
private AssignedFaultRepository assignedFaultRepository;

@GetMapping("/assigned_faults/all")
    public @ResponseBody Iterable<AssignedFault> getAllAssignedFaults() {
    return assignedFaultRepository.findAll();
  }
}
@RestController
@请求映射(路径=“/accounts”)
公共类用户控制器{
@自动连线
私有用户存储库用户存储库;
@GetMapping(“/users/all”)
public@ResponseBody Iterable getAllUsers(){
返回userRepository.findAll();
}
}
这是我用来获取数据的php代码

<?php

  $ch = curl_init();


   curl_setopt($ch, CURLOPT_URL, "http://localhost:8932/springrest/accounts/users/all");
   curl_setopt($ch, CURLOPT_HEADER, 0);

   curl_exec($ch);
   curl_close($ch);
?>

当我从内联网外部点击php页面时,它返回ERR\u EMPTY\u响应

这是如此令人费解,因为使用相同的php代码并将url更改为http://localhost:8932/springrest/faults/assigned_faults/all 我得到了预期的JSON响应

这是控制器

@RestController
@RequestMapping(path="/accounts")
public class UserController {
@Autowired
private UserRepository userRepository;

@GetMapping("/users/all")
public @ResponseBody Iterable<User> getAllUsers() {

      return userRepository.findAll();
  }
}
@RestController 
@RequestMapping(path="/faults")
public class AssignedFaultController {
@Autowired 
   
private AssignedFaultRepository assignedFaultRepository;

@GetMapping("/assigned_faults/all")
    public @ResponseBody Iterable<AssignedFault> getAllAssignedFaults() {
    return assignedFaultRepository.findAll();
  }
}
@RestController
@请求映射(路径=“/faults”)
公共类分配的FaultController{
@自动连线
专用AssignedFaultRepository AssignedFaultRepository;
@GetMapping(“/assigned\u faults/all”)
public@ResponseBody Iterable getAllAssignedFaults(){
返回assignedFaultRepository.findAll();
}
}