org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter Java Examples
The following examples show how to use
org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RequestPartIntegrationTests.java From spring-analysis-note with MIT License | 7 votes |
@Before public void setup() { ByteArrayHttpMessageConverter emptyBodyConverter = new ByteArrayHttpMessageConverter(); emptyBodyConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON)); List<HttpMessageConverter<?>> converters = new ArrayList<>(3); converters.add(emptyBodyConverter); converters.add(new ByteArrayHttpMessageConverter()); converters.add(new ResourceHttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter()); AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter(); converter.setPartConverters(converters); restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); restTemplate.setMessageConverters(Collections.singletonList(converter)); }
Example #2
Source File: RouterFunctionMapping.java From spring-analysis-note with MIT License | 6 votes |
/** * Initializes a default set of {@linkplain HttpMessageConverter message converters}. */ private void initMessageConverters() { List<HttpMessageConverter<?>> messageConverters = new ArrayList<>(4); messageConverters.add(new ByteArrayHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter()); try { messageConverters.add(new SourceHttpMessageConverter<>()); } catch (Error err) { // Ignore when no TransformerFactory implementation is available } messageConverters.add(new AllEncompassingFormHttpMessageConverter()); this.messageConverters = messageConverters; }
Example #3
Source File: RequestResponseBodyMethodProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void resolveArgumentRawTypeFromParameterizedType() throws Exception { String content = "fruit=apple&vegetable=kale"; this.servletRequest.setMethod("GET"); this.servletRequest.setContent(content.getBytes("UTF-8")); this.servletRequest.setContentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE); List<HttpMessageConverter<?>> converters = new ArrayList<>(); converters.add(new AllEncompassingFormHttpMessageConverter()); RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters); @SuppressWarnings("unchecked") MultiValueMap<String, String> result = (MultiValueMap<String, String>) processor.resolveArgument( paramMultiValueMap, container, request, factory); assertNotNull(result); assertEquals("apple", result.getFirst("fruit")); assertEquals("kale", result.getFirst("vegetable")); }
Example #4
Source File: WebConfiguration.java From java-platform with Apache License 2.0 | 6 votes |
@Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(Charset.forName("UTF-8")); stringConverter.setWriteAcceptCharset(false); converters.add(new ByteArrayHttpMessageConverter()); converters.add(stringConverter); converters.add(new ResourceHttpMessageConverter()); converters.add(new SourceHttpMessageConverter<Source>()); converters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #5
Source File: RequestPartIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Before public void setup() { ByteArrayHttpMessageConverter emptyBodyConverter = new ByteArrayHttpMessageConverter(); emptyBodyConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON)); List<HttpMessageConverter<?>> converters = new ArrayList<>(3); converters.add(emptyBodyConverter); converters.add(new ByteArrayHttpMessageConverter()); converters.add(new ResourceHttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter()); AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter(); converter.setPartConverters(converters); restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); restTemplate.setMessageConverters(Collections.singletonList(converter)); }
Example #6
Source File: RequestResponseBodyMethodProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void resolveArgumentRawTypeFromParameterizedType() throws Exception { String content = "fruit=apple&vegetable=kale"; this.servletRequest.setMethod("GET"); this.servletRequest.setContent(content.getBytes("UTF-8")); this.servletRequest.setContentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE); List<HttpMessageConverter<?>> converters = new ArrayList<>(); converters.add(new AllEncompassingFormHttpMessageConverter()); RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters); @SuppressWarnings("unchecked") MultiValueMap<String, String> result = (MultiValueMap<String, String>) processor.resolveArgument( paramMultiValueMap, container, request, factory); assertNotNull(result); assertEquals("apple", result.getFirst("fruit")); assertEquals("kale", result.getFirst("vegetable")); }
Example #7
Source File: RequestResponseBodyMethodProcessorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void resolveArgumentRawTypeFromParameterizedType() throws Exception { String content = "fruit=apple&vegetable=kale"; this.servletRequest.setMethod("GET"); this.servletRequest.setContent(content.getBytes("UTF-8")); this.servletRequest.setContentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE); List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>(); converters.add(new AllEncompassingFormHttpMessageConverter()); RequestResponseBodyMethodProcessor processor = new RequestResponseBodyMethodProcessor(converters); @SuppressWarnings("unchecked") MultiValueMap<String, String> result = (MultiValueMap<String, String>) processor.resolveArgument( paramMultiValueMap, mavContainer, webRequest, binderFactory); assertNotNull(result); assertEquals("apple", result.getFirst("fruit")); assertEquals("kale", result.getFirst("vegetable")); }
Example #8
Source File: RequestPartIntegrationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Before public void setUp() { ByteArrayHttpMessageConverter emptyBodyConverter = new ByteArrayHttpMessageConverter(); emptyBodyConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON)); List<HttpMessageConverter<?>> converters = new ArrayList<>(3); converters.add(emptyBodyConverter); converters.add(new ByteArrayHttpMessageConverter()); converters.add(new ResourceHttpMessageConverter()); converters.add(new MappingJackson2HttpMessageConverter()); AllEncompassingFormHttpMessageConverter converter = new AllEncompassingFormHttpMessageConverter(); converter.setPartConverters(converters); restTemplate = new RestTemplate(new HttpComponentsClientHttpRequestFactory()); restTemplate.setMessageConverters(Collections.singletonList(converter)); }
Example #9
Source File: HttpClientConfig.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
private List<HttpMessageConverter<?>> converters() { List<HttpMessageConverter<?>> result = Lists.newArrayList(); result.add(new ByteArrayHttpMessageConverter()); result.add(new StringHttpMessageConverter()); result.add(new ResourceHttpMessageConverter()); result.add(new SourceHttpMessageConverter<>()); result.add(new AllEncompassingFormHttpMessageConverter()); result.add(new Jaxb2RootElementHttpMessageConverter()); result.add(gsonHttpMessageConverter); return result; }
Example #10
Source File: DefaultAuthServiceImpl.java From SENS with GNU General Public License v3.0 | 5 votes |
public static RestTemplate getRestTemplate() {// 手动添加 SimpleClientHttpRequestFactory requestFactory=new SimpleClientHttpRequestFactory(); requestFactory.setReadTimeout(120000); List<HttpMessageConverter<?>> messageConverters = new LinkedList<>(); messageConverters.add(new ByteArrayHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8)); messageConverters.add(new ResourceHttpMessageConverter()); messageConverters.add(new SourceHttpMessageConverter<Source>()); messageConverters.add(new AllEncompassingFormHttpMessageConverter()); messageConverters.add(new MappingJackson2HttpMessageConverter()); RestTemplate restTemplate=new RestTemplate(messageConverters); restTemplate.setRequestFactory(requestFactory); return restTemplate; }
Example #11
Source File: RestTemplateFactory.java From sdk-rest with MIT License | 5 votes |
private static RestTemplate createRestTemplate() { List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>(); messageConverters.add(new ByteArrayHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter(Charset.forName("UTF-8"))); messageConverters.add(new ResourceHttpMessageConverter()); messageConverters.add(new SourceHttpMessageConverter<Source>()); messageConverters.add(new AllEncompassingFormHttpMessageConverter()); messageConverters.add(new Jaxb2RootElementHttpMessageConverter()); messageConverters.add(new MappingJackson2HttpMessageConverter()); return new RestTemplate(messageConverters); }
Example #12
Source File: SpringParameterProvider.java From katharsis-framework with Apache License 2.0 | 5 votes |
private List<HttpMessageConverter<?>> getHttpMessageConverters() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 List<HttpMessageConverter<?>> converters = new ArrayList<>(4); converters.add(new ByteArrayHttpMessageConverter()); converters.add(stringHttpMessageConverter); converters.add(new SourceHttpMessageConverter<>()); converters.add(new AllEncompassingFormHttpMessageConverter()); return converters; }
Example #13
Source File: RestTemplate.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new instance of the {@link RestTemplate} using default settings. * Default {@link HttpMessageConverter}s are initialized. */ public RestTemplate() { this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(new StringHttpMessageConverter()); this.messageConverters.add(new ResourceHttpMessageConverter()); this.messageConverters.add(new SourceHttpMessageConverter<Source>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); if (romePresent) { this.messageConverters.add(new AtomFeedHttpMessageConverter()); this.messageConverters.add(new RssChannelHttpMessageConverter()); } if (jackson2XmlPresent) { this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter()); } else if (jaxb2Present) { this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter()); } if (jackson2Present) { this.messageConverters.add(new MappingJackson2HttpMessageConverter()); } else if (gsonPresent) { this.messageConverters.add(new GsonHttpMessageConverter()); } }
Example #14
Source File: RequestMappingHandlerAdapter.java From spring4-understanding with Apache License 2.0 | 5 votes |
public RequestMappingHandlerAdapter() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 this.messageConverters = new ArrayList<HttpMessageConverter<?>>(4); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); this.messageConverters.add(new SourceHttpMessageConverter<Source>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #15
Source File: ExceptionHandlerExceptionResolver.java From spring4-understanding with Apache License 2.0 | 5 votes |
public ExceptionHandlerExceptionResolver() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // See SPR-7316 this.messageConverters = new ArrayList<HttpMessageConverter<?>>(); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); this.messageConverters.add(new SourceHttpMessageConverter<Source>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #16
Source File: HttpMessageConverterConfiguration.java From apollo with Apache License 2.0 | 5 votes |
@Bean public HttpMessageConverters messageConverters() { GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter(); gsonHttpMessageConverter.setGson( new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create()); final List<HttpMessageConverter<?>> converters = Lists.newArrayList( new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(), new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter); return new HttpMessageConverters() { @Override public List<HttpMessageConverter<?>> getConverters() { return converters; } }; }
Example #17
Source File: RestTemplate.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new instance of the {@link RestTemplate} using default settings. * Default {@link HttpMessageConverter}s are initialized. */ public RestTemplate() { this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(new StringHttpMessageConverter()); this.messageConverters.add(new ResourceHttpMessageConverter()); this.messageConverters.add(new SourceHttpMessageConverter<Source>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); if (romePresent) { this.messageConverters.add(new AtomFeedHttpMessageConverter()); this.messageConverters.add(new RssChannelHttpMessageConverter()); } if (jackson2XmlPresent) { this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter()); } else if (jaxb2Present) { this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter()); } if (jackson2Present) { this.messageConverters.add(new MappingJackson2HttpMessageConverter()); } else if (gsonPresent) { this.messageConverters.add(new GsonHttpMessageConverter()); } }
Example #18
Source File: RequestMappingHandlerAdapter.java From lams with GNU General Public License v2.0 | 5 votes |
public RequestMappingHandlerAdapter() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 this.messageConverters = new ArrayList<HttpMessageConverter<?>>(4); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); this.messageConverters.add(new SourceHttpMessageConverter<Source>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #19
Source File: ExceptionHandlerExceptionResolver.java From lams with GNU General Public License v2.0 | 5 votes |
public ExceptionHandlerExceptionResolver() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 this.messageConverters = new ArrayList<HttpMessageConverter<?>>(); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); this.messageConverters.add(new SourceHttpMessageConverter<Source>()); this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #20
Source File: RequestMappingHandlerAdapter.java From java-technology-stack with MIT License | 5 votes |
public RequestMappingHandlerAdapter() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 this.messageConverters = new ArrayList<>(4); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); try { this.messageConverters.add(new SourceHttpMessageConverter<>()); } catch (Error err) { // Ignore when no TransformerFactory implementation is available } this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #21
Source File: ExceptionHandlerExceptionResolver.java From java-technology-stack with MIT License | 5 votes |
public ExceptionHandlerExceptionResolver() { StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter(); stringHttpMessageConverter.setWriteAcceptCharset(false); // see SPR-7316 this.messageConverters = new ArrayList<>(); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(stringHttpMessageConverter); try { this.messageConverters.add(new SourceHttpMessageConverter<>()); } catch (Error err) { // Ignore when no TransformerFactory implementation is available } this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #22
Source File: RequestMappingHandlerAdapter.java From spring-analysis-note with MIT License | 5 votes |
public RequestMappingHandlerAdapter() { this.messageConverters = new ArrayList<>(4); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(new StringHttpMessageConverter()); try { this.messageConverters.add(new SourceHttpMessageConverter<>()); } catch (Error err) { // Ignore when no TransformerFactory implementation is available } this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #23
Source File: ExceptionHandlerExceptionResolver.java From spring-analysis-note with MIT License | 5 votes |
public ExceptionHandlerExceptionResolver() { this.messageConverters = new ArrayList<>(); this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(new StringHttpMessageConverter()); try { this.messageConverters.add(new SourceHttpMessageConverter<>()); } catch (Error err) { // Ignore when no TransformerFactory implementation is available } this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); }
Example #24
Source File: WebMvcConfigurationSupport.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Adds a set of default HttpMessageConverter instances to the given list. * Subclasses can call this method from {@link #configureMessageConverters(List)}. * @param messageConverters the list to add the default message converters to */ protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) { StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(); stringConverter.setWriteAcceptCharset(false); messageConverters.add(new ByteArrayHttpMessageConverter()); messageConverters.add(stringConverter); messageConverters.add(new ResourceHttpMessageConverter()); messageConverters.add(new SourceHttpMessageConverter<Source>()); messageConverters.add(new AllEncompassingFormHttpMessageConverter()); if (romePresent) { messageConverters.add(new AtomFeedHttpMessageConverter()); messageConverters.add(new RssChannelHttpMessageConverter()); } if (jackson2XmlPresent) { messageConverters.add(new MappingJackson2XmlHttpMessageConverter( Jackson2ObjectMapperBuilder.xml().applicationContext(this.applicationContext).build())); } else if (jaxb2Present) { messageConverters.add(new Jaxb2RootElementHttpMessageConverter()); } if (jackson2Present) { messageConverters.add(new MappingJackson2HttpMessageConverter( Jackson2ObjectMapperBuilder.json().applicationContext(this.applicationContext).build())); } else if (gsonPresent) { messageConverters.add(new GsonHttpMessageConverter()); } }
Example #25
Source File: FormConverterInitializer.java From spring-fu with Apache License 2.0 | 4 votes |
@Override public void initialize(GenericApplicationContext context) { context.registerBean("allEncompassingFormHttpMessageConverter", HttpMessageConverter.class, AllEncompassingFormHttpMessageConverter::new); }
Example #26
Source File: RestTemplate.java From java-technology-stack with MIT License | 4 votes |
/** * Create a new instance of the {@link RestTemplate} using default settings. * Default {@link HttpMessageConverter HttpMessageConverters} are initialized. */ public RestTemplate() { this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(new StringHttpMessageConverter()); this.messageConverters.add(new ResourceHttpMessageConverter(false)); try { this.messageConverters.add(new SourceHttpMessageConverter<>()); } catch (Error err) { // Ignore when no TransformerFactory implementation is available } this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); if (romePresent) { this.messageConverters.add(new AtomFeedHttpMessageConverter()); this.messageConverters.add(new RssChannelHttpMessageConverter()); } if (jackson2XmlPresent) { this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter()); } else if (jaxb2Present) { this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter()); } if (jackson2Present) { this.messageConverters.add(new MappingJackson2HttpMessageConverter()); } else if (gsonPresent) { this.messageConverters.add(new GsonHttpMessageConverter()); } else if (jsonbPresent) { this.messageConverters.add(new JsonbHttpMessageConverter()); } if (jackson2SmilePresent) { this.messageConverters.add(new MappingJackson2SmileHttpMessageConverter()); } if (jackson2CborPresent) { this.messageConverters.add(new MappingJackson2CborHttpMessageConverter()); } this.uriTemplateHandler = initUriTemplateHandler(); }
Example #27
Source File: FormHttpMessageConverterTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Before public void setUp() { this.converter = new AllEncompassingFormHttpMessageConverter(); }
Example #28
Source File: RestTemplate.java From spring-analysis-note with MIT License | 4 votes |
/** * Create a new instance of the {@link RestTemplate} using default settings. * Default {@link HttpMessageConverter HttpMessageConverters} are initialized. */ public RestTemplate() { this.messageConverters.add(new ByteArrayHttpMessageConverter()); this.messageConverters.add(new StringHttpMessageConverter()); this.messageConverters.add(new ResourceHttpMessageConverter(false)); try { this.messageConverters.add(new SourceHttpMessageConverter<>()); } catch (Error err) { // Ignore when no TransformerFactory implementation is available } this.messageConverters.add(new AllEncompassingFormHttpMessageConverter()); if (romePresent) { this.messageConverters.add(new AtomFeedHttpMessageConverter()); this.messageConverters.add(new RssChannelHttpMessageConverter()); } if (jackson2XmlPresent) { this.messageConverters.add(new MappingJackson2XmlHttpMessageConverter()); } else if (jaxb2Present) { this.messageConverters.add(new Jaxb2RootElementHttpMessageConverter()); } if (jackson2Present) { this.messageConverters.add(new MappingJackson2HttpMessageConverter()); } else if (gsonPresent) { this.messageConverters.add(new GsonHttpMessageConverter()); } else if (jsonbPresent) { this.messageConverters.add(new JsonbHttpMessageConverter()); } if (jackson2SmilePresent) { this.messageConverters.add(new MappingJackson2SmileHttpMessageConverter()); } if (jackson2CborPresent) { this.messageConverters.add(new MappingJackson2CborHttpMessageConverter()); } this.uriTemplateHandler = initUriTemplateHandler(); }