开发者

spring AbstractExcelView and IE

开发者 https://www.devze.com 2023-02-13 13:43 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消