Support HttpMessageConverter refs in mvc namespace
Issue: SPR-9469
This commit is contained in:
parent
62f2858f7f
commit
ecce7520fb
|
|
@ -397,10 +397,9 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
|||
ManagedList<? super Object> messageConverters = new ManagedList<Object>();
|
||||
if (convertersElement != null) {
|
||||
messageConverters.setSource(source);
|
||||
for (Element converter : DomUtils.getChildElementsByTagName(convertersElement, "bean")) {
|
||||
BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(converter);
|
||||
beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
|
||||
messageConverters.add(beanDef);
|
||||
for (Element beanElement : DomUtils.getChildElementsByTagName(convertersElement, new String[] { "bean", "ref" })) {
|
||||
Object object = parserContext.getDelegate().parsePropertySubElement(beanElement, null);
|
||||
messageConverters.add(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,13 +33,22 @@
|
|||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element ref="beans:bean" minOccurs="1" maxOccurs="unbounded">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
The HttpMessageConverter bean definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element ref="beans:bean">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
An HttpMessageConverter bean definition.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element ref="beans:ref">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
A reference to an HttpMessageConverter bean.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="register-defaults" type="xsd:boolean" default="true">
|
||||
<xsd:annotation>
|
||||
|
|
|
|||
|
|
@ -2,14 +2,17 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
||||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
|
||||
|
||||
<mvc:annotation-driven>
|
||||
<mvc:message-converters register-defaults="false">
|
||||
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
|
||||
<bean class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
|
||||
<ref bean="stringConverter" />
|
||||
<ref bean="resourceConverter" />
|
||||
</mvc:message-converters>
|
||||
</mvc:annotation-driven>
|
||||
|
||||
<bean id="stringConverter" class="org.springframework.http.converter.StringHttpMessageConverter"/>
|
||||
<bean id="resourceConverter" class="org.springframework.http.converter.ResourceHttpMessageConverter"/>
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
Loading…
Reference in New Issue