使用Glassfish V3在IE中提供swf文件的问题

时间:2010-11-22 12:29:27

标签: internet-explorer flash glassfish jersey

我有使用glassfish来提供swf文件的问题。 在我的应用程序中有一个小的swf文件在数据表上使用TableTools插件,当我尝试用任何浏览器打开这个页面时一切都很好,但是IE的行为是完全不同的swf没有加载,如果我试图达到它使用直接网址提醒我要求我选择浏览器与文件的关系(打开,保存,另存为),点击打开但没有显示任何内容。 此问题仅出现在IE中。 它似乎是一个内容类型错误,因为chrome告诉我这个警告: “资源被解释为文档,但使用MIME类型application / x-shockwave-flash传输。”

但我不知道如何设置正确的内容类型 我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>ManagementConsole</display-name>
    <filter>
        <filter-name>jersey</filter-name>
        <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
            <param-value>/(img|js|css)/.*</param-value>
        </init-param>
        <init-param>
            <param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
            <param-value>/WEB-INF/jsp</param-value>
        </init-param>
    </filter>
    <filter>
        <filter-name>RedirectWrongRequest</filter-name>
        <filter-class>com.italtel.patchfinder.filters.RedirectWrongRequest</filter-class>
        <init-param>
            <param-name>exclude</param-name>
            <param-value>/LoginServlet</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>RedirectWrongRequest</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>jersey</filter-name>
        <url-pattern>/admin/*</url-pattern>
    </filter-mapping>
    <servlet>
        <servlet-name>LoginServlet</servlet-name>
        <jsp-file>/WEB-INF/jsp/login.jsp</jsp-file>
    </servlet>
    <servlet>
        <servlet-name>LoginError</servlet-name>
        <jsp-file>/WEB-INF/jsp/loginError.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>LoginServlet</servlet-name>
        <url-pattern>/LoginServlet</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>LoginError</servlet-name>
        <url-pattern>/LoginError</url-pattern>
    </servlet-mapping>
    <jsp-config>
        <taglib>
            <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
            <taglib-location>/WEB-INF/c.tld</taglib-location>
        </taglib>
    </jsp-config>
    <security-constraint>
        <display-name>AdminPages</display-name>
        <web-resource-collection>
            <web-resource-name>admin</web-resource-name>
            <description/>
            <url-pattern>/admin/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>HEAD</http-method>
            <http-method>PUT</http-method>
            <http-method>OPTIONS</http-method>
            <http-method>TRACE</http-method>
            <http-method>DELETE</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>admin</role-name>
            <!--<role-name>USERS</role-name>-->
        </auth-constraint>
        <user-data-constraint>
            <!--None in http mode, Confidential in https mode-->
            <!--<transport-guarantee>NONE</transport-guarantee>-->
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/LoginServlet</form-login-page>
            <form-error-page>/LoginError</form-error-page>
        </form-login-config>
        <!--<realm-name>userauth</realm-name>-->
    </login-config>
    <security-role>
        <description/>
        <role-name>admin</role-name>
        <!--<role-name>USERS</role-name>-->
    </security-role>
    <welcome-file-list>
        <welcome-file>Menu</welcome-file>
    </welcome-file-list>
</web-app>

从下面的图片中可以看到最后3行,错误加载swf文件(内容类型正确)

http://i.stack.imgur.com/Jh98S.png

1 个答案:

答案 0 :(得分:0)

我找到了解决方案! 问题是IE 6/7/8/9中的一个错误,也许是旧版本,当使用安全连接ssl时,加载swf文件不成功,因为IE中的错误。 我通过在我的应用程序中使用过滤器覆盖缓存来解决这个问题:

        hresponse.setDateHeader("Expires", -1);
        hresponse.setDateHeader("Last-Modified", System.currentTimeMillis());
        hresponse.setHeader("Pragma", "");
        hresponse.setHeader("cache-control", "must-revalidate");

希望对别人有用! 感谢