Spring Web @RequestHeader(Map<String,String>) throws RuntimeException
See original GitHub issueDescribe the bug
I’m trying to access all request headers using Spring @RequestHeader
in the same way that @Context HttpHeaders headers
would provide access to all request headers.
When starting the application with mvn quarkus:dev
, I get the following exception
Caused by: java.lang.RuntimeException: RESTEASY003875: Unable to find a constructor that takes a String param or a valueOf() or fromString() method for javax.ws.rs.HeaderParam(“headers”) on public java.lang.String org.acme.SpringGreetingController.hello(java.util.Map) for basetype: java.util.Map
Expected behavior A populated Map with HTTP headers, preferably a MultiValuedMap.
Actual behavior Above exception.
To Reproduce
See reproducer. Note, I’d like to use the Spring MultiValueMap
, although the reproducer uses a Map
.
The reproducer is literally a project generated from code.quarkus.io with the Spring Web extension, with the hello()
method updated as follows;
public String hello(@RequestHeader MultiValueMap<String, String> headers) {
headers.forEach((key, value) -> {
System.out.println(key + "->" + value);
})
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
I will likely work on this after the 2.2 stabilization release is out
@liangyuanpeng yup, as you mention one can mix and match the Spring and JAX-RS annotations and types.