【发布时间】:2010-11-23 23:17:05
【问题描述】:
我在使用 glassfish 来提供 swf 文件时遇到问题。 在我的应用程序中,有一个小 swf 文件可以在数据表上使用 TableTools 插件,当我尝试使用任何浏览器打开此页面时一切正常,但使用 IE 时行为完全不同,swf 未加载,如果我尝试访问它使用直接 url 的警报要求我选择浏览器与文件的关系(打开、保存、另存为),我单击打开但没有显示任何内容.. 这个问题只出现在 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 文件时出错(内容类型正确)
【问题讨论】:
-
Headers: 请求 URL:0.0.0.0/ManagementConsole/swf/a.swf 请求方法:GET 状态码:200 OK 请求头接受:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain ;q=0.8,image/png,/;q=0.5 User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 响应头 Accept-Ranges:bytes Content-Length:1871 Content-Type:application/x-shockwave-flash 日期:Mon, 22 Nov 2010 15:09:11 GMT ETag:W/"1871 -1290437702000" 最后修改时间:星期一,2010 年 11 月 22 日 14:55:02 GMT 服务器:GlassFish v3 X-Powered-By:Servlet/3.0
标签: internet-explorer flash glassfish jersey