further marshalling work
This commit is contained in:
@@ -1,16 +1,44 @@
|
||||
package org.baeldung.config;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
@ComponentScan({ "org.baeldung.web" })
|
||||
public class WebConfig {
|
||||
|
||||
public WebConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
package org.baeldung.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
|
||||
import org.springframework.oxm.xstream.XStreamMarshaller;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ComponentScan({ "org.baeldung.web" })
|
||||
public class WebConfig extends WebMvcConfigurerAdapter {
|
||||
|
||||
public WebConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
|
||||
messageConverters.add(marshallingHttpMessageConverter());
|
||||
messageConverters.add(new MappingJackson2HttpMessageConverter());
|
||||
|
||||
super.configureMessageConverters(messageConverters);
|
||||
}
|
||||
|
||||
// UTIL
|
||||
|
||||
private final MarshallingHttpMessageConverter marshallingHttpMessageConverter() {
|
||||
final MarshallingHttpMessageConverter marshallingHttpMessageConverter = new MarshallingHttpMessageConverter();
|
||||
final XStreamMarshaller xstreamMarshaller = new XStreamMarshaller();
|
||||
marshallingHttpMessageConverter.setMarshaller(xstreamMarshaller);
|
||||
marshallingHttpMessageConverter.setUnmarshaller(xstreamMarshaller);
|
||||
|
||||
return marshallingHttpMessageConverter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user