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;
@ -101,6 +104,20 @@ public class MvcConfig implements WebMvcConfigurer {
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