Spring AbstractExcelView and IE

I use spring ContentNegotiatingViewResolverto export data to excel files. This works fine in Chrome and FireFox, but in IE, instead of downloading, File Explorer displays gibberish in the browser.

This is my piece of configuration:

<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?

+3
source share
1 answer

The problem was setting the content type in the response header; it was not installed. I installed it manually and it solves the problem

0
source

Source: https://habr.com/ru/post/1795078/


All Articles