I have a simple Spring Boot controller like this:

public class TestController { 

   @DeleteMapping 
   public ResponseEntity<?> deleteTest(String[] keywords) { 
     return new ResponseEntity<>(keywords, HttpStatus.OK);
   }

} 

If I make a request to http://localhost:8090/test?keywords=%20%20%20%201, the result is "1".

However, if I make a request to http://localhost:8090/test?keywords=%20%20%20%201&keywords=%20%20%20%202, the result is: [ " 1", " 2" ]

Why are whitespaces removed only when the array size is 1? I also tested with a simple String parameter (not an array), but the issue did not occur. I also tested with + instead of %20 for encoding spaces, but the result was the same.

0

There are 0 best solutions below