【问题标题】:Struts2 File Upload doesn't work on Internet-ExplorerStruts2 文件上传在 Internet-Explorer 上不起作用
【发布时间】:2015-04-24 15:43:34
【问题描述】:

我在 Internet Explorer 中为 Word 文件(.docx、.doc)上传 Struts 2 文件时遇到问题。它在 Chrome 和 Firefox 中运行良好,但我不确定我在 IE 中缺少什么。 我正在使用 IE9。 感谢您的建议。

<action name="saveOrUpdateUser" method="saveOrUpdate"
            class="com.adaptivsol.action.UsersAction">
    <interceptor-ref name="defaultStack">
        <param name="fileUpload.maximumSize">104857600</param>
        <param name="allowedTypes">
                text/plain,                 
                application/word,
                application/msword,
                application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
                application/vnd.openxmlformats-officedocument.wordprocessingml.document
        </param>
        <param name="allowedExtensions">doc,docx,txt</param>
    </interceptor-ref>
    <result name="success">./pages/login/register.jsp</result>
    <result name="input">./pages/login/register.jsp</result>
    <result name="error">./pages/login/register.jsp</result>
</action>

【问题讨论】:

  • 您在使用 IE9 时遇到了什么问题?请更新问题,说明它是如何不工作的。谢谢!
  • 这是一个文件上传功能。该文件使用 Fire Fox 和 Chrome 浏览。在 Internet Explorer 上,拦截器会阻止提交操作。我尝试了几个版本的拦截器,甚至完全删除了它,它们都在 Chrome 上工作,但在 IE9 上没有运气。

标签: file-upload struts2 internet-explorer-9


【解决方案1】:

你的参数错误,其中两个缺少fileUpload.前缀,应该是:

<param name="fileUpload.allowedTypes">
    text/plain,                 
    application/word,
    application/msword,
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
    application/vnd.openxmlformats-officedocument.wordprocessingml.document
</param>
<param name="fileUpload.allowedExtensions">doc,docx,txt</param>

顺便说一下,在struts.xml 中将devMode 设置为true,并在此处发布文件上传停止工作的日志。我们需要看到一个错误、一个警告、一个消息,或者一些东西来理解什么是错误的。

还在您的 JSP 中添加 actionerrors, actionmessagesfielderrors 打印功能,并在此处报告您收到的消息。

【讨论】:

  • 感谢您的支持。我已根据您的建议更改了 。即使在 Chrome 中也能再次工作。我删除了拦截器,它在 Chrome 中完美运行,在 IE 中它从未命中服务器端代码。这就是为什么它从不填充任何错误。只是页面正在重新上传。
猜你喜欢
  • 2016-01-18
  • 1970-01-01
  • 1970-01-01
  • 2012-07-31
  • 1970-01-01
  • 2013-07-05
  • 1970-01-01
  • 1970-01-01
  • 2020-02-23
相关资源
最近更新 更多