79145141

Date: 2024-10-31 14:36:42
Score: 0.5
Natty:
Report link

Resolved by adding WebMvcConfig code.

@Configuration

public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN)
              .mediaType("json", MediaType.APPLICATION_JSON)
              .mediaType("text", MediaType.TEXT_PLAIN)
              .parameterName("mediaType")
              .favorPathExtension(true);
}

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
    converters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
    converters.add(new MappingJackson2HttpMessageConverter());
}
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: kaidey