Announcement Announcement Module
Collapse
No announcement yet.
Handling multiple media types Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling multiple media types

    HI,
    Is it possible to handle multiple media types using ByteArrayHttpMessageConverter ?
    The scenario i have is, i won't be able to tell the exact type that i have to render beforehand.
    i will come to know about the type of document after fetching the document. is it possible to write a handler that can handle all the media types? if not can we write individual handlers ?
    I have tried the following ,
    Code:
    <bean id="byteArrayMessageConverter"
    
    		class="org.springframework.http.converter.ByteArrayHttpMessageConverter">
    
    		<property name="supportedMediaTypes">
    			<list>
    				
    				<bean class="org.springframework.http.MediaType">
    					<constructor-arg value="application" />
    					<constructor-arg value="pdf" />
    				</bean>
    				<bean class="org.springframework.http.MediaType">
    					<constructor-arg value="text" />
    					<constructor-arg value="plain" />
    				</bean>
    				<bean class="org.springframework.http.MediaType">
    					<constructor-arg value="text" />
    					<constructor-arg value="csv" />
    				</bean>
    				<bean class="org.springframework.http.MediaType">
    					<constructor-arg value="text" />
    					<constructor-arg value="xml" />
    				</bean>
    				<bean class="org.springframework.http.MediaType">
    					<constructor-arg value="application" />
    					<constructor-arg value="msword" />
    				</bean>
    				<bean class="org.springframework.http.MediaType">
    					<constructor-arg value="application" />
    					<constructor-arg value="vnd.ms-excel" />
    				</bean>
                                     </list>
    		</property>
    	</bean>
    But the problem i face, ms excel is taking precedence over the rest of the converters (say, if i get an image back, it tries to open it with excel ). Any pointers on this?

    Thanks,
    Paary
Working...
X