使用 Glassfish V3 在 IE 中提供 swf 文件时出现问题
我在使用 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 文件时出错(具有正确的内容类型)
I have a problem with glassfish to serve swf files.
In my application there is a little swf file to use TableTools plugin on datatable and when I try to open this page with any browser everything goes fine, but with IE the behaviour is quite different the swf is not loaded and if I try to reach it with direct url an alert ask me to choice what the browser has to do with the file (Open, Save, Save as), I click on open but nothing is shown..
This problem appear only with IE.
it seems a content-type error because chrome show me this warning:
"Resource interpreted as document but transferred with MIME type application/x-shockwave-flash."
but I don't know how I can setup the correct content-type
my 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>
from the image below you can see last 3 rows with the error loading swf file (with correct content-type)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决办法!
问题是 IE 6/7/8/9 甚至更早版本中的错误,当使用安全连接 ssl 时,由于 IE 中的错误,加载 swf 文件不会成功。
我通过在应用程序中使用过滤器覆盖缓存解决了这个问题:
希望对其他人有用!
谢谢
I found a solution!
problem was a bug in IE 6/7/8/9 and maybe older version, where when using a secure connection ssl, loading of swf file doesn't succeed because a bug in IE.
I've solved this problem by overriding the cache with a filter in my application:
hope will be useful for someone else!
Thanks