Skip to content

Commit

Permalink
Merge pull request #303 from bnyte/fix_297
Browse files Browse the repository at this point in the history
fix: Backend api responds garbled in browser (#297)
  • Loading branch information
vainhope authored Mar 24, 2022
2 parents 21866ef + 3fefe56 commit fe56768
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.*;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -56,10 +57,11 @@ public LoginInterceptor loginInterceptor() {
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter();
List<MediaType> mediaTypes = new ArrayList<>();
mediaTypes.add(MediaType.TEXT_PLAIN);
mediaTypes.add(MediaType.APPLICATION_JSON);
mediaTypes.add(MediaType.MULTIPART_FORM_DATA);
mediaTypes.add(MediaType.parseMediaType(MediaType.TEXT_PLAIN_VALUE));
mediaTypes.add(MediaType.parseMediaType(MediaType.APPLICATION_JSON_VALUE));
mediaTypes.add(MediaType.parseMediaType(MediaType.MULTIPART_FORM_DATA_VALUE));
mappingJackson2HttpMessageConverter.setSupportedMediaTypes(mediaTypes);
mappingJackson2HttpMessageConverter.setDefaultCharset(StandardCharsets.UTF_8);
converters.add(0, mappingJackson2HttpMessageConverter);
super.configureMessageConverters(converters);
}
Expand Down

0 comments on commit fe56768

Please sign in to comment.