I am using spring's ContentNegotiatingViewResolver
in order to export data to excel files.
This works perfectly in Chrome and FireFox, however in IE instead of downloading the file Explorer displays gibberish in the browser.
This my config snippet:
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"
p:order="1">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml" />
<entry key="txt" value="text/plain" />
<entry key="xls" value="application/vnd.ms-excel" />
<entry key="bin" value="multipart/form-data" />
</map>
</property>开发者_如何转开发;
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<property name="marshaller" ref="oxmMarshaller" />
<property name="modelKey" value="response" />
</bean>
<bean name="excel" class="myclass.MyExcelViewResolver" />
</list>
</property>
</bean>
any ideas?
The problem was setting the content-type in the response header, it was not set. I set it manually and it solves the problem
精彩评论