同一个表单,ie和firefox发送的表单不同,为什么?
我有一个表单,如果我只填写英文字符,一切都可以,但是如果我尝试填写一些中文字符,则会出现问题:
如果在 chrome 或 firefox 中填写表单,则发送以下内容请求:
/docsearch/documents/site/test/documentLibrary/?filter=path&filterData=%2F&size=50&pos=1&prop_cm_name=%E4%B8%AD%E5%9B%BD HTTP /1.1
如果在 IE 中填写表单,则发送以下请求: /doclib/docsearch/documents/site/test/documentLibrary/?filter=path&filterData=%2F&size=50&pos=1&prop_cm_name=\326\320\271\372 HTTP/1.1
如您所见,相同中文字符在 IE 和 Firefox 中可以有不同的编码。有人可以告诉我如何让 IE 发送与 firefox/chrome 相同的请求吗?
编辑表单:
<form action="" enctype="application/json" accept-charset="utf-8" method="post" id="template_x002e_toolbar_x002e_documentlibrary-form" forms-runtime="listening" onsubmit="return false;">
<div class="form-fields" id="template_x002e_toolbar_x002e_documentlibrary-form-fields">
<div class="form-field">
<label for="template_x002e_toolbar_x002e_documentlibrary_prop_cm_name">Name:</label>
<input type="text" title="Name" value="" tabindex="0" name="prop_cm_name" id="template_x002e_toolbar_x002e_documentlibrary_prop_cm_name">
</div>
</form>
似乎 IE 将这些字符视为 Unicode,而不是根据表单中的参数将这些字符视为 UTF8?
I have a form, and if I only fill in English characters, everything is OK, but if I tried to fill in some Chinese characters, then problem happens:
If fill in the form in chrome or firefox, then it sent following request:
/docsearch/documents/site/test/documentLibrary/?filter=path&filterData=%2F&size=50&pos=1&prop_cm_name=%E4%B8%AD%E5%9B%BD HTTP/1.1
If fill in the form in IE, then it sent following request:
/doclib/docsearch/documents/site/test/documentLibrary/?filter=path&filterData=%2F&size=50&pos=1&prop_cm_name=\326\320\271\372 HTTP/1.1
As you can see, same Chinese characters can have different encoding within IE and firefox. Can someone tell me how to make IE send the same requests as firefox/chrome ?
EDIT form:
<form action="" enctype="application/json" accept-charset="utf-8" method="post" id="template_x002e_toolbar_x002e_documentlibrary-form" forms-runtime="listening" onsubmit="return false;">
<div class="form-fields" id="template_x002e_toolbar_x002e_documentlibrary-form-fields">
<div class="form-field">
<label for="template_x002e_toolbar_x002e_documentlibrary_prop_cm_name">Name:</label>
<input type="text" title="Name" value="" tabindex="0" name="prop_cm_name" id="template_x002e_toolbar_x002e_documentlibrary_prop_cm_name">
</div>
</form>
It seems that IE treat those characters as Unicode, but not UTF8 as per the parameter in form?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要从
form
元素中删除enctype
属性,或为其选择以下值之一:您使用的值
application/json
可能会导致您看到的差异,因为不同的浏览器可能会处理enctype
的未知值> 属性不同。请参阅此处了解更多信息。
You may need to either remove the
enctype
attribute from theform
element, or choose one of the following values for it:The value you're using,
application/json
, might be causing the difference you're seeing, as different browsers may handle an unknown value of theenctype
attribute differently.See here for more info.