-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathMvcConfig.java
More file actions
29 lines (24 loc) · 1.09 KB
/
MvcConfig.java
File metadata and controls
29 lines (24 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.prgms.springbootbasic.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
import org.springframework.oxm.xstream.XStreamMarshaller;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/v1/**")
.allowedOrigins("*");
}
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
MarshallingHttpMessageConverter messageConverter = new MarshallingHttpMessageConverter();
XStreamMarshaller marshaller = new XStreamMarshaller();
messageConverter.setMarshaller(marshaller);
messageConverter.setUnmarshaller(marshaller);
converters.add(messageConverter);
}
}