Reputation: 215
I set up an api endpoint for a get request. The parameter is a String array where each String is a character separated list of numbers, like ["dr:1/2/3"]
@GetMapping("/getmapping")
public ResponseEntity<JsonNode> getRequest(String[] list) {
...
}
The problem is when I pass in a string like this ["dr:1,2,3"]
and the parameter gets automatically split into ["dr:1", "2", "3"]
Is there a way to stop the string from being split automatically?
I could use a different character to separate the numbers besides a comma and it would work, but then how would I validate if commas are being used so I can throw an appropriate error?
Upvotes: 0
Views: 266
Reputation: 18979
No what you want is some extremely custom behavior to be supported by spring.
What you can do is the following
@GetMapping("/getmapping")
public ResponseEntity<JsonNode> getRequest(String param) {
String[] parts = param.split("/"); //Here you have the information as you want it to
...
}
Upvotes: 1