I am using apache wicket stuff REST, and in a simple API... I would like to get the list of headers and simply display it as debug log.
My problem is I am getting an error java.util.UnknownFormatConversionException
From Code:
@MethodMapping(value="/testSubmit", httpMethod=HttpMethod.POST)
public Object testSubmit() {
return "OK";
}
To Code:
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.http.HttpHeaders;
...
@MethodMapping(value="/testSubmit", httpMethod=HttpMethod.POST)
public Object testSubmit(@RequestHeader HttpHeaders headers) {
// Display request headers here
return "OK";
}
I think the problem is @RequestHeader
, HttpHeaders
which are from springframework.
If I can get the wicketstuff equivalent for these... I will not get the error.
Any idea on how I could fix these or the wicketstuff equivalent for getting the list of request headers?
Thanks
Since I only need to display the list of headers in the request, I used
HttpServletRequest
then callgetHeaderNames()
to get the header names.Iterate then the header names to get the header values.
To get the HttpServletRequest in wicketstuff rest, in my case I called it like:
HttpServletRequest request = (HttpServletRequest) getCurrentWebRequest().getContainerRequest();
Note:
getCurrentWebRequest()
is fromorg.wicketstuff.rest.resource.AbstractRestResource
, andgetContainerRequest()
is fromorg.apache.wicket.request.Request.getContainerRequest()
So, to display the header info:
System.out.println(getHeaderInfo(request));
Which is just what I need, I just need this to reflect in my debug log
Hope this helps