RestEasy csv 文件上传(多部分/表单数据)在 FireFox 中乱码 iso-8859-1 字符
我有一个多部分/表单数据表单,用于将 csv 文件上传到轻松 (JAX RS) Web 服务。该文件可以包含 iso-8859-1 字符,例如 é。当我通过 Firefox 上传文件时,这些字符出现乱码,最终变成一个 ? 。当我通过 Internet Explorer 上传文件时,一切正常。
我做了很多阅读,发现 Firefox 结合 multipart / form-data 和 charset 属性存在问题(enctype='multipart/form-data; charset=ISO-8859-1') 不起作用。
所以我尝试在 HTML 页面中设置 (我也尝试设置 text/html 或 multipart/form-data 而不是 text/csv 但这些似乎都没有什么区别
我浏览了其余的简单 api 并发现了一些关于“覆盖 multipart 的默认后备内容类型”的内容。找不到内容类型时的默认后备是 us-ascii。我尝试处理的字符 (é,..) 不存在于 us-ascii 中,因此它们最终会出现乱码。覆盖此默认后备内容类型似乎也没有帮助(请参阅: http://docs.jboss.org/resteasy/docs/1.2.GA/userguide/html/Multipart.html)
那么当我说 Internet Explorer 发送 content-type+ 时,我是对的吗http 标头中的字符集正确,所以一切顺利,而 Firefox 在尝试与 multipart/form-data 组合时发送内容类型/字符集时会搞砸吗?我已经通过 stackoverflow 进行了搜索,但似乎没有一个已批准的解决方案适用于我的情况。
以前有人遇到过这个具体问题吗? (使用 Jboss Rest Easy 框架上传多部分/表单数据文件)?我还可以尝试其他方法吗?
提前致谢!
雅尼克
I have a multipart / form-data form to upload a csv file to a rest easy (JAX RS) webservice. This file can contain
iso-8859-1 characters like for example é. When I upload the file through Firefox these characters are garbled and they end up like a ?. When I upload the file through Internet Explorer everything works fine.
I've done a lot of reading and found out that there's a problem in firefox combining multipart / form-data and the charset attribute (enctype='multipart/form-data; charset=ISO-8859-1'
) doesn't work.
So I've tried setting <meta http-equiv="Content-Type" content="text/csv; charset=iso-8859-1" />
in my HTML page (I also tried setting text/html or multipart/form-data in stead of text/csv but none of that seems to make a difference.
I went through the rest easy api and found something about 'overwriting the default fallback content type for multipart messages'. The default fallback when no content type is found is us-ascii. The characters I try to process (é,..) don't exist in us-ascii so it makes sense they end up garbled. Overriding this default fallback content type doesn't seem to help either (see: http://docs.jboss.org/resteasy/docs/1.2.GA/userguide/html/Multipart.html)
So am I right when I say that Internet Explorer sends the content-type+charset correctly in the http header, so everything goes well. And that firefox messes things up while trying to send the content-type/charset while combined with multipart/form-data? I have done my searching through stackoverflow but none of the approved solutions seem to work in my case.
Has anybody had this specific problem before? (multipart / form-data file upload using Jboss rest easy framework)? Something else I can try?
Thanks in advance!
Yannick
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论