簡體   English   中英

Internet Explorer從我的Web應用程序更改了包含特殊字符的文件的文件名

[英]Internet Explorer changes filename of a file containing special character from my web application

我有一個支持文件下載的Web應用程序。 在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不喜歡它,因為它用於網絡錨(即url#anchor)。 要了解發生了什么:

  1. 確保服務器實際上發送了您期望的文件名(查看網絡上的HTTP響應標頭;使用用於瀏覽器或支持日志記錄的本地代理服務器的開發工具)

  2. 編輯代碼以將各種奇數字符放入文件名中,以查看哪些字符可以,哪些字符不能

  3. 嘗試使用其他瀏覽器; 可能是Windows在瀏覽器嘗試保存文件時重命名該文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM