The problem:
I’m trying to receive multiples resources in single Mapping of the controller. I need to take these resources and use to access the data in MongoDB.
Example:
If the access is in: mydomain.com/rootresource/datakey1/datakey2
I want to get the resources after rootresource for use to search data in MongoDB. The number of resources after rootresource is not a fixed.
My actual controller:
@RestController
@RequestMapping("users")
public class UserController {
@Autowired
private UserService service;
@PostMapping
public void create(@RequestBody UserCreateRequest request) {
service.create(request.getAccess(), request.getPassword(), request.getData());
}
@GetMapping("/{access}")
public UserDTO readByAccess(@PathVariable("access") String access) {
return service.read(access);
}
@GetMapping("/{data:[\\/.]*}")
public Document readByAccessAndData(@PathVariable("data") String data) {
return null;
}
}
My actual tentative is in readByAccessAndData
function. When I call the url .../users/key1/key2
the received error is:
{
"timestamp": "2019-09-21T22:22:31.262+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/users/key1/key2"
}