xmlView 추가

master
mjkhan21 12 months ago
parent d572362191
commit 80453ca7ba

@ -16,8 +16,11 @@ import org.springframework.web.servlet.view.BeanNameViewResolver;
import org.springframework.web.servlet.view.JstlView; import org.springframework.web.servlet.view.JstlView;
import org.springframework.web.servlet.view.UrlBasedViewResolver; import org.springframework.web.servlet.view.UrlBasedViewResolver;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView; import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
import org.springframework.web.servlet.view.xml.MappingJackson2XmlView;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
import cokr.xit.foundation.web.AccessInitializer; import cokr.xit.foundation.web.AccessInitializer;
@ -96,11 +99,25 @@ public class MvcConfig implements WebMvcConfigurer {
@Bean @Bean
public MappingJackson2JsonView jsonView() { public MappingJackson2JsonView jsonView() {
MappingJackson2JsonView bean = new MappingJackson2JsonView(); MappingJackson2JsonView bean = new MappingJackson2JsonView();
bean.setContentType("application/json;charset=UTF-8"); bean.setContentType("application/json; charset=UTF-8");
bean.setObjectMapper(objectMapper); bean.setObjectMapper(objectMapper);
return bean; return bean;
} }
/**MappingJackson2XmlView .
* @return MappingJackson2XmlView
*/
@Bean
public MappingJackson2XmlView xmlView() {
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
MappingJackson2XmlView bean = new MappingJackson2XmlView();
bean.setContentType("application/xml; charset=UTF-8");
bean.setObjectMapper(xmlMapper);
return bean;
}
/**CommonsMultipartResolver . /**CommonsMultipartResolver .
* @return CommonsMultipartResolver * @return CommonsMultipartResolver
*/ */

Loading…
Cancel
Save