Affects: spring 5.3.30 with spring boot 2.7.17 and JDK11
Description: I want to request a website using get method
e.g. I want to request https://127.0.0.1:8080?first=1&second=2 using get method
demo:
@RestController
@AllArgsConstructor
public class TestController {
private RestTemplate restTemplate;
@GetMapping("/test")
public String test(){
var params = new HashMap<>();
params.put("first", "1");
params.put("second", "2");
ResponseEntity<String> entity = restTemplate.getForEntity("http://127.0.0.1:8080", String.class, params);
return entity.getBody();
}
@GetMapping
public String testGet(@RequestParam String first,@RequestParam String second){
return "OK";
}
}
Demo throw exception when I request the link http://127.0.0.1:8080/test
org.springframework.web.client.HttpClientErrorException$BadRequest: 400 : "{"timestamp":"2023-11-14T09:53:57.621+00:00","status":400,"error":"Bad Request","path":"/"}"
at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:101) ~[spring-web-5.3.30.jar:5.3.30]
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:168) ~[spring-web-5.3.30.jar:5.3.30]
...
I don't know what's wrong with this,The result shows that the demo request link lost parameters.
Comment From: bclozel
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.