Spring MVC - Internet Explorer 7 and JSON
here's a little "trick" i found out with IE 7... if you're ever in the situation where you need to send JSON directly to the client (say, in an IFrame scenario), IE7 will misunderstand the application/json type and pop up the download dialog. so, to counter this in Spring MVC 3, add the following to the annotations for the MessageConverter...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:mvc="http://www.springframework.org/schema/mvc" | |
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd | |
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | |
<mvc:annotation-driven> | |
<mvc:message-converters> | |
<bean | |
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> | |
<property name="supportedMediaTypes" value="text/plain"/> | |
</bean> | |
</mvc:message-converters> | |
</mvc:annotation-driven> | |
</beans> |
No comments:
Post a Comment