logo
down
shadow

How to set the default content type in Spring MVC in no Accept header is provided?


How to set the default content type in Spring MVC in no Accept header is provided?

By : Roman Draliuk
Date : November 25 2020, 07:27 PM
I hope this helps you . From the Spring documentation, you can do this with Java config like this:
code :


Share : facebook icon twitter icon
RFC2616 algorithm for default content using Accept-Language header

RFC2616 algorithm for default content using Accept-Language header


By : sachin
Date : March 29 2020, 07:55 AM
it should still fix some issue What you want is a Locale fallback. For HTTP Accept-Language header I18n best practice rules are:
Given lang-country pair return the contents if it is available Then try to return the content for given language, if it is available Then try the next language on the list (start from 1) If nothing works so far, return (application | server) default language.
Does get request need content type and accept header?

Does get request need content type and accept header?


By : Vivek
Date : March 29 2020, 07:55 AM
it should still fix some issue content-type : It is not required in the GET request as you are not sending any content in the request body.
Set default content type header of Spring RestTemplate

Set default content type header of Spring RestTemplate


By : Arun
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I'm currently using an OAuth2RestOperations that extends the Spring RestTemplate and I would like to specify the content type header. , First you have to create request interceptor:
code :
public class JsonMimeInterceptor implements ClientHttpRequestInterceptor {

  @Override
  public ClientHttpResponse intercept(HttpRequest request, byte[] body,
        ClientHttpRequestExecution execution) throws IOException {
    HttpHeaders headers = request.getHeaders();
    headers.add("Accept", MediaType.APPLICATION_JSON);
    return execution.execute(request, body);
  }
}
@Configuration
public class MyAppConfig {

  @Bean
  public RestTemplate restTemplate() {
      RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory());
      restTemplate.setInterceptors(Collections.singletonList(new JsonMimeInterceptor()));
      return restTemplate;
  }
}
spring kafka No type information in headers and no default type provided

spring kafka No type information in headers and no default type provided


By : Julien Berrier
Date : March 29 2020, 07:55 AM
like below fixes the issue See the documentation.
Specifically...
How to specify to accept multipart/related content type with particular content types for body part in the accept header

How to specify to accept multipart/related content type with particular content types for body part in the accept header


By : user5390066
Date : March 29 2020, 07:55 AM
I wish this help you To start off, HTTP is a MIME-like protocol, not a MIME-compliant one. To quote RFC 7230, section 2.1:
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org