gpt4 book ai didi

java - Internet Explorer 更改包含来 self 的 Web 应用程序的特殊字符的文件的文件名

转载 作者:行者123 更新时间:2023-11-28 23:45:17 25 4
gpt4 key购买 nike

我有一个支持文件下载的网络应用程序。它在 Firefox 和 Chrome 上运行良好。但是对于 Internet Explorer,当我下载一个包含特殊字符的文件时,例如:#,它总是将字符更改为下划线:_

例如,文件filename#.zip 在我从Internet Explorer 下载后将保存为filename_.zip

Web 应用程序本身是使用 GWT 和 Java 编写的。 Web 应用程序由 Tomcat 托管。我使用的IE版本是IE11。

我知道发布这个问题有点含糊,因为我不能在这里发布我的整个 Web 应用程序代码。欢迎任何想法。

更新:

这是我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">

<listener>
<listener-class>com.mycompany.somelistener</listener-class>
</listener>

<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>

<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>

<session-config>
<session-timeout>10</session-timeout>
</session-config>

<security-constraint>
<web-resource-collection>
<web-resource-name>webApp</web-resource-name>
<url-pattern>*</url-pattern>
</web-resource-collection>

<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>

</web-app>

最佳答案

Windows 不允许在文件名中包含多个字符 ( \ / : * ? " < > | source ) 但 #应该没问题。

也许 IE 不喜欢它,因为它用于网络 anchor (即 url#anchor)。要了解发生了什么:

  1. 确保服务器实际发送了您期望的文件名(查看网络上的 HTTP 响应 header ;使用浏览器的开发工具或支持日志记录的本地代理服务器)

    <
  2. 编辑代码,在文件名中加入各种奇怪的字符,看看哪些字符可以,哪些不可以

  3. 尝试使用不同的浏览器;当浏览器尝试保存文件时,Windows 可能正在重命名该文件。

关于java - Internet Explorer 更改包含来 self 的 Web 应用程序的特殊字符的文件的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15064997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com