As per my understanding you need to get output even it contains whitespaces
GET: localhost:8080/v1/test/?name =test
GET: localhost:8080/v1/test/?name=test
so i suggest you can use, "Map<String,String>" instead of String.
Below code is my sample code you can refer it and you can use accordingly
@RequestMapping("/api")
public class DemoController {
@GetMapping("/person/id")
private String getStudent(@RequestParam Map<String,String> name) throws Exception {
String value = null;
if((name.get("g") !=null) || (name.get("g ")) !=null)
{
value = "even";
}
else {
value ="odd";
}
return value;
}
}
changes would be
@RequestParam Map<String,String> name
- i have changed
and introduced a condition to check if((name.get("g") !=null) || (name.get("g ")) !=null)
Thanks :)