diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java
index f2ffba68b5..d7ebaed73d 100644
--- a/spring-web/src/main/java/org/springframework/http/MediaType.java
+++ b/spring-web/src/main/java/org/springframework/http/MediaType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -123,6 +123,18 @@ public class MediaType extends MimeType implements Serializable {
*/
public final static String APPLICATION_PDF_VALUE = "application/pdf";
+ /**
+ * Public constant media type for {@code application/rss+xml}.
+ * @since 4.3.6
+ */
+ public final static MediaType APPLICATION_RSS_XML;
+
+ /**
+ * A String equivalent of {@link MediaType#APPLICATION_RSS_XML}.
+ * @since 4.3.6
+ */
+ public final static String APPLICATION_RSS_XML_VALUE = "application/rss+xml";
+
/**
* Public constant media type for {@code application/xhtml+xml}.
*/
@@ -183,6 +195,19 @@ public class MediaType extends MimeType implements Serializable {
*/
public final static String MULTIPART_FORM_DATA_VALUE = "multipart/form-data";
+ /**
+ * Public constant media type for {@code text/event-stream}.
+ * @since 4.3.6
+ * @see Server-Sent Events W3C recommendation
+ */
+ public final static MediaType TEXT_EVENT_STREAM;
+
+ /**
+ * A String equivalent of {@link MediaType#TEXT_EVENT_STREAM}.
+ * @since 4.3.6
+ */
+ public final static String TEXT_EVENT_STREAM_VALUE = "text/event-stream";
+
/**
* Public constant media type for {@code text/html}.
*/
@@ -237,12 +262,14 @@ public class MediaType extends MimeType implements Serializable {
APPLICATION_JSON_UTF8 = valueOf(APPLICATION_JSON_UTF8_VALUE);
APPLICATION_OCTET_STREAM = valueOf(APPLICATION_OCTET_STREAM_VALUE);
APPLICATION_PDF = valueOf(APPLICATION_PDF_VALUE);
+ APPLICATION_RSS_XML = valueOf(APPLICATION_RSS_XML_VALUE);
APPLICATION_XHTML_XML = valueOf(APPLICATION_XHTML_XML_VALUE);
APPLICATION_XML = valueOf(APPLICATION_XML_VALUE);
IMAGE_GIF = valueOf(IMAGE_GIF_VALUE);
IMAGE_JPEG = valueOf(IMAGE_JPEG_VALUE);
IMAGE_PNG = valueOf(IMAGE_PNG_VALUE);
MULTIPART_FORM_DATA = valueOf(MULTIPART_FORM_DATA_VALUE);
+ TEXT_EVENT_STREAM = valueOf(TEXT_EVENT_STREAM_VALUE);
TEXT_HTML = valueOf(TEXT_HTML_VALUE);
TEXT_MARKDOWN = valueOf(TEXT_MARKDOWN_VALUE);
TEXT_PLAIN = valueOf(TEXT_PLAIN_VALUE);
diff --git a/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java
index 9e7b897e6a..432a2ae5ee 100644
--- a/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java
+++ b/spring-web/src/main/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ import org.springframework.http.MediaType;
public class RssChannelHttpMessageConverter extends AbstractWireFeedHttpMessageConverter {
public RssChannelHttpMessageConverter() {
- super(new MediaType("application", "rss+xml"));
+ super(MediaType.APPLICATION_RSS_XML);
}
@Override
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
index dd80a15a9a..a9efe29498 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -433,7 +433,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
Properties props = new Properties();
if (romePresent) {
props.put("atom", MediaType.APPLICATION_ATOM_XML_VALUE);
- props.put("rss", "application/rss+xml");
+ props.put("rss", MediaType.APPLICATION_RSS_XML_VALUE);
}
if (jaxb2Present || jackson2XmlPresent) {
props.put("xml", MediaType.APPLICATION_XML_VALUE);
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
index 1510a539f9..229f2dbadf 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,7 +73,6 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.HandlerAdapter;
import org.springframework.web.servlet.HandlerExceptionResolver;
-import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
@@ -381,7 +380,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
Map map = new HashMap(4);
if (romePresent) {
map.put("atom", MediaType.APPLICATION_ATOM_XML);
- map.put("rss", MediaType.valueOf("application/rss+xml"));
+ map.put("rss", MediaType.APPLICATION_RSS_XML);
}
if (jaxb2Present || jackson2XmlPresent) {
map.put("xml", MediaType.APPLICATION_XML);
diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java
index a390e087b3..0003ea5b51 100644
--- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java
+++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/feed/AbstractRssFeedView.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ import javax.servlet.http.HttpServletResponse;
import com.rometools.rome.feed.rss.Channel;
import com.rometools.rome.feed.rss.Item;
+import org.springframework.http.MediaType;
+
/**
* Abstract superclass for RSS Feed views, using the
* ROME package.
@@ -46,9 +48,10 @@ import com.rometools.rome.feed.rss.Item;
public abstract class AbstractRssFeedView extends AbstractFeedView {
public AbstractRssFeedView() {
- setContentType("application/rss+xml");
+ setContentType(MediaType.APPLICATION_RSS_XML_VALUE);
}
+
/**
* Create a new Channel instance to hold the entries.
*
By default returns an RSS 2.0 channel, but the subclass can specify any channel.