Selaa lähdekoodia

增加xml控制视频器

zhouy 1 vuosi sitten
vanhempi
commit
fa79f0b2e5

+ 16 - 0
uas-office-qywx-server/src/main/java/com/usoftchina/uas/office/qywx/config/WebMvcConfig.java

@@ -1,10 +1,16 @@
 package com.usoftchina.uas.office.qywx.config;
 
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.http.HttpHeaders;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
+
+import java.util.List;
 
 /**
  * @author yingp
@@ -32,6 +38,16 @@ public class WebMvcConfig implements WebMvcConfigurer {
         registry.addViewController("/addrbook").setViewName("addrbook.html");
         registry.addViewController("/corp").setViewName("corp.html");
     }
+
+    @Bean
+    public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
+        RequestMappingHandlerAdapter adapter = new RequestMappingHandlerAdapter();
+        List<HttpMessageConverter<?>> converters = adapter.getMessageConverters();
+        MappingJackson2XmlHttpMessageConverter xmlConverter = new MappingJackson2XmlHttpMessageConverter();
+        converters.add(xmlConverter);
+        adapter.setMessageConverters(converters);
+        return adapter;
+    }
 }