This question is in reference of the question:
Setting the response content-type without using HttpServletResponse
with the following code:
@RequestMapping("handle.htm")
public ResponseEntity<String> handle() {
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentType(new MediaType("text", "plain"));
//responseHeaders.set("myheader","xyz");
return new ResponseEntity<String>("Hello World", responseHeaders, HttpStatus.CREATED);
}
I am getting following error:
java.lang.NoSuchMethodError: org.springframework.http.HttpHeaders.readOnlyHttpHeaders(Lorg/springframework/http/HttpHeaders;)Lorg/springframework/http/HttpHeaders;
org.springframework.http.HttpEntity.<init>(HttpEntity.java:100)
org.springframework.http.HttpEntity.<init>(HttpEntity.java:70)
org.springframework.http.HttpEntity.<clinit>(HttpEntity.java:58)
...
But in spring API docs there is a static method:
static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers)
Then why it is giving such error?
Thanks…
I have had a look in the code, and it must work. Double check everything that you do not use different (old) versions of that jar.